shouldcomponentupdate example

Example 1: componentDidUpdate

componentDidUpdate(prevProps, prevState) {
  if (prevState.pokemons !== this.state.pokemons) {
    console.log('pokemons state has changed.')
  }
}

Example 2: lifecycle method react

INITIALIZATION= setup props and state 
MOUNTING= constructor->componentWillMount->render->componentDidMount//Birth
UPDATE= shouldComponentUpdate->componentWillUpdate->render
  		->componentDidUpdate //Growth
UNMOUNTING= componentWillUnmount //Death

Example 3: shouldcomponentupdate

shouldComponentUpdate(nextProps, nextState) {
  return true;
}

Example 4: component did mmount

componentDidUpdate(prevProps, prevState, snapshot)

Example 5: shouldcomponentupdate default return

By default, shouldComponentUpdate returns true, but you can override it to return false for cases that you do not want a re-render.