본문 바로가기

카테고리 없음

# 3. State

#3.2 Component life cycles

 

1. mounting

constructor() : 클래스를 만들 때 자바스크립트에서 호출. 

rennder()

componentDidMount():컴포넌트가 render 됐음을 알려줌. 

 

2. update

shouldComponentUpdate(): 기본적으로 업데이트를 할지 말지 결정하는 것. 

render();

componentDidUpdate()

 

3. unmounting

Component가 죽는 경우 - Change page, replace component, ..

componentWillUnmount()

 

#3.3 Planning the Movie Component

매번 this.state.isLoading 하기 귀찮다. ES6의 어썸한 기능을 써보자. 

const {isLoading} = this.state;

 

퀴즈. 미래에 일어날 state를 모두 state안에 미리 적어둬야할까?

답은 No. book:true는 error를 일으키지 않을 것이다. 미래에 사용할 state를 모두 명시하는게 필수는 아니다.