shouldComponentUpdate
-
React shouldComponentUpdate vs PureComponentStudy/React 2020. 1. 18. 10:49
shouldComponentUpdate - 컴포넌트가 업데이트 되는 시점에 호출되는 메서드 - 컴포넌트가 리렌더링 할지 말지를 결정하는 메서드 기본형태 shouldComponentUpdate(nextProps, nextState) { if(조건) { return true; } return false; }; - 리렌더링 할 조건을 작성한다 - true를 리턴하면 리렌더링하고, false를 리턴하면 리렌더링하지 않는다. 예시 import React, {Component} from 'react'; class Counter extends Component { state = { number: 0 }; shouldComponentUpdate(nextProps, nextState) { if(this.state.num..