-
[7]Pure Component가 뭔가?dev/Web 2021. 4. 12. 19:00
React.PureComponent는 React.Component와 비슷하다. 하지만 PureComponent에서는 shouldComponentUpdate가 이미 구현되어 있는데, props와 state를 얕은 비교를 통해 비교한뒤 변경된 것이 있을 때만 리렌더링 한다.
- state로 인한 불필요한 렌더링을 방지하기 위해 사용된다. → 성능 향상
얕은 비교를 사용하기 때문에 props와 state의 구조가 간단하면 PureComponent를 사용할 수 있다.
깊은 자료 구조의 변화가 있다면 forceUpdate()를 사용한다.
'dev > Web' 카테고리의 다른 글
[9]React에서 Prop은 무엇인가? (0) 2021.04.12 [8]React에서 state는 무엇인가? (0) 2021.04.12 [6]Class Component를 사용하는 이유 (0) 2021.04.12 [5]React Component를 생성하는 법 (0) 2021.04.12 [4]Element와 Component의 차이 (0) 2021.04.12