Open cannalee90 opened 6 years ago
어렴풋이 알고있었던거 다시 정리
componentWillMount()
에서 defaultProps
에서 stateProps
가 넘어오는줄 알았는데, 문서를 다시 읽어보니까 애초에 connect()
함수가 HOC
니까 redux에 있는 props들이 처음부터 넘어오는 것이었다.componentDidMount()
에서 fetch를 하도록 하는게 맞다. 서버사이드 렌더링을 할 경우 componentWillMount()
가 호출되기 때문에 componentDidMount()
에서 호출하는게 맞다.initilize
construct()
state를 초기화 한다 defaultProps과 새로운 Props들을 머지한다 Component를 생성할때 딱 한번만 호출된다.
Mounting
componentWillMount
render
가 되기전 딱 한번 호출된다.construct()
와 통합해야한다는 토론이 이어지고 있음.render()
componentDidMount()
fetch()
를 하기 좋은 위치Update
새로운 props
를 받거나 state
를 업데이트할때 발동
state
가 업데이트 될때는 다음과 같이 호출된다
shouldComponentUpdate()
componentWillUpdate()
shouldComponentUpdate()
가 true를 리턴하면 실행된다.
특정 아이템을 렌더하기전 계산이나 준비를 할때 사용하면 된다.
render()
componentDidUpdate()
componentWillReceiveProps
props
이 바뀔때 생성된다.props
에 의존적인 state
를 업데이트할때 사용된다. 이곳에서 state를 업데이트해도 새롭게 리렌더링되지 않음shouldComponentUpdate
componentWillUpdate
render
componentDidUpdate
가 실행된다
Unmounting
뭔가 잘못알고 있었던 점이 있었던거 같다