1. alignSelf, alignItems, alignContent
- align-self: grid나 flex item를 정렬, flexBox 내에서 교차 축에 정렬 즉, flexDirection에 따라 교차 축이 달라짐
- align-Items: 상위 요소에서 아이템들을 일괄적으로 적용
- align-content: flexBox의 교차축을 따라 content items 사이의 간격 설정, 두 줄부터 사용해야 의미있다, flex-wrap: wrap;인 상태에서 사용(nowrap이면 의미 없음)
https://dkrnfls.tistory.com/247
https://letsgojieun.tistory.com/49
2. Hooks
https://ko.legacy.reactjs.org/docs/hooks-effect.html
3. import, require()
- import: 일반 자바스크립트(ES6부터) 지원, 파일 최상단에 작성
- require(): node.js 환경에서 사용, 파일 어느 곳이든 가능
import {모듈명} from '모듈경로'; // javascript
const 모듈명 = require('모듈경로'); // node.js
https://www.codeit.kr/community/questions/UXVlc3Rpb246NjM5YjNlMGViYzIzODgzZmRjNWRlMmMx
4. Object 메서드
- Object.create(proto, propertiesObject): 새로운 객체를 만드는 메서드, 이미 존재하는 객체를 새롭게 생성하는 객체의 프로토타입(->상속)으로 사용, propertiesObject는 프로퍼티 값을 설정하는 객체
- Object.values(Obj): 주어진 객체의 열거형이자 문자열 키로 구성된 프로퍼티의 값을 배열로 반환, for...in loop과 기능 동일
for...in loop은 prototype chain에서도 프로퍼티를 열거할 수 있다, objects.values는 불가
(cf. prototype chain: 객체가 다른 객체들로부터 프로퍼티와 메서드를 상속받을 수 있는 메카니즘) - Object.entries(Obj): 주어진 객체의 열거형이자 문자열 키로 구성된 프로퍼티와 그 값을 페어로 하여 각각을 배열로 반환, 전체 반환된 타입도 배열
https://2ssue.github.io/common_questions_for_Web_Developer/docs/Javascript/2_Object.create.html#참고
- new 연산자 vs. Object.create(proto) by chatGPT
아래는 코드 예제
function Vehicle(name, maxSpeed) {
this.name = name;
this.maxSpeed = maxSpeed;
}
Vehicle.prototype.information = function() {
console.log(`${this.name} can move to ${this.maxSpeed}km/h`);
};
function LightCar(name, maxSpeed, currentSpeed) {
Vehicle.call(this, name, maxSpeed);
this.currentSpeed = currentSpeed;
}
// Vehicle을 상속받도록 설정
LightCar.prototype = Object.create(Vehicle.prototype);
// constructor를 다시 LightCar로 설정
LightCar.prototype.constructor = LightCar;
LightCar.prototype.currentSpeedInfo = function() {
console.log(`${this.name} is currently moving at ${this.currentSpeed}km/h`);
};
const lightCar = new LightCar('light car', 150, 80);
console.log(lightCar.constructor === LightCar); // true
const object1 = {
a: 'somestring',
b: 42,
1: 'numeric',
};
for (const [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
};
// "1: numeric"
// "a: somestring"
// "b: 42"
console.log(typeof Object.entries(object1)); // Object - 자바스크립트 설정 오류
console.log(Array.isArray(Object.entries(object1))); // true
console.log(Object.entries(object1)); // Array [Array ["1", "numeric"], Array ["a", "somestring"], Array ["b", 42]]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
'FrontEnd > React Native' 카테고리의 다른 글
[RN] JS- 계산된 속성 이름, 속성 정의 및 접근 방법 (0) | 2024.05.27 |
---|---|
[RN] VSCode prettier 적용, 오류 해결 (0) | 2024.05.23 |
[RN] 연산자 종류 (==, !=, ===, !==) (0) | 2024.05.22 |
[RN] Props 중괄호 사용 (feat. 구조 분해 할당) (0) | 2024.05.22 |
[RN] Button 표현 방법, state, event 정리 _ 처음 배우는 리액트 네이티브 (24.05.13) (0) | 2024.05.14 |