Lifecycle

이나영·2021년 10월 10일
0

React

목록 보기
8/10

1. 생성

constructor 생성
→ render가 이루어지면서
→ DOM 업데이트
→ 컴포넌트가 다 그려진 직후에
componentDidMount

componentDidMount는 오로지 처음 생성 시에만 사용된다. 이후에는 componentDidUpdate가 작동된다.

2. 업데이트

New props / setState() / forceUpdate()
→ render가 이루어지면서
→ DOM 업데이트
→ 컴포넌트가 다 그려진 직후에
componentDidUpdate

forceUpdate()는 이름에서 알 수 있듯이 강제적인 수단임으로 가능한 사용하지 않는다.

3. 제거

사라지기 직전에
= componentWillUnmount

※ 부모 - 자식 Lifecycle 순서

- 부모 contructor
→ 부모 render
→ 자식 contructor
→ 자식 render
→ 자식 componentDidMount
→ 부모 componentDidMount

0개의 댓글