https://medium.com/bitsrc/react-16-lifecycle-methods-how-and-when-to-use-them-f4ad31fb2282
React 16 Lifecycle Methods: How and When to Use Them
A revised and up-to-date guide to the new React component lifecycle
blog.bitsrc.io
리액트의 생명주기
컴포넌트는 생성(mounting) → 업데이트(updating) → 제거(unmounting)의 생명주기를 갖는다.
- 클래스 컴포넌트 → Lifecycle methods
- 함수형 컴포넌트 → Hook
클래스 컴포넌트의 생명주기
Mounting
- constructor
- getDerivedStateFromProps
- render
- componentDidMount
Updating
- getDerivedStateFromProps
- shouldComponentUpdate
- render
- getSnapshotBeforeUpdate (New!)
- componentDidUpdate
Unmounting
- componentWillUnmount
Errors
- getDerivedStateFromError
- componentDidCatch
클래스 컴포넌트가 어떤 순서로 어떤 함수를 사용하며 렌더링 되는지 전체적인 틀은 잡혔는데, 아무래도 직접 구현해 보기 전까지는 두루뭉술한 상태일 것 같다.
🤔 클래스 컴포넌트 생명주기 구현
'Today I Learned' 카테고리의 다른 글
[스위디 3월] ChatGPT 케이스 스터디 (0) | 2023.03.09 |
---|---|
[스위디 3월] 1주 차 회고 (0) | 2023.03.06 |
[아티클 DB] 10 Best Database Design Practices (0) | 2023.02.20 |
[아티클 DB] Things I Wished More Developers Knew About Databases (0) | 2023.02.13 |
[2022.01.21. 클린 코드] 시작 ~ 들어가면서 (0) | 2022.11.09 |