
- Mounting
- 가장 처음 실행되는 단계
- constructor에서 모든 것이 이루어지며, state와 prop, component 등을 준비시킴
- rendering
- constructor에서는 http request와 같은 side effect를 실행시키지 말 것
- 총 4가지 메서드
- constructor()
- static getDerivedStateFromProps()
- render()
- componentDidMount()
- Updating
- state나 prop이 바뀌어 re-rendering이 필요할 때
- 총 5가지 메서드
- static getDerivedStateFromProps()
- shouldComponentUpdate()
- render()
- getSnapshotBeforeUpdate()
- componentDidUpdate()
- Unmounting
- component가 DOM에서 삭제되는 단계
- 단 1개 메서드
- componentWillUmount()
- useEffect()
- 컴포넌트가 렌더링 될 때마다 특정 작업을 실행할 수 있도록 하는 Hook
- useEffect( FUNCTION, DEPS )
- deps : 배열이며, 배열 안에 검사하고자 하는 특정 값 / 빈 배열
- useEffect 사용법
- Component가 mount됐을 때 한 번만 실행
deps에 빈 배열 넣기 - re-rendering 될 때마다 실행
deps 생략 - Component가 update 될 때마다 실행
deps에 검사할 값
- Component가 mount됐을 때 한 번만 실행
https://www.c-sharpcorner.com/article/components-lifecycle-in-react/
Components Lifecycle In React
React component lifecycle is defined by the sequence of methods executed in different stages of the component’s existence. This article talks about component lifecycle in React.
www.c-sharpcorner.com
https://xiubindev.tistory.com/100
React Hooks : useEffect() 함수
useEffect 함수는 리액트 컴포넌트가 렌더링 될 때마다 특정 작업을 실행할 수 있도록 하는 Hook 이다. useEffect는 component가 mount 됐을 때, component가 unmount 됐을 때, component가 update 됐을 때, 특정..
xiubindev.tistory.com
'프레임워크 > React Native' 카테고리의 다른 글
[ReactNative] FCM+AsyncStorage 설치 후 build failed (0) | 2022.02.18 |
---|---|
[ReactNative] Windows 프로젝트 생성 및 안드로이드 실행 (0) | 2022.02.07 |
React에서 string 안에 ${변수} 사용 (0) | 2021.07.12 |
React Native Tutorial (JSX, Component, State, Prop) (0) | 2021.07.09 |
WSL(Windows Subsystem for Linux)에서 React Native 설치 (0) | 2021.06.27 |