The second updating lifecycle method is called
When a component updates,
shouldComponentUpdate gets called after
componentWillReceiveProps, but still before the rendering begins.
Look at Example.js in the code editor. Read it through and try to figure out how
shouldComponentUpdate should return either
true, then nothing noticeable happens. But if
false, then the component will not update! None of the remaining lifecycle methods for that updating period will be called, including
The best way to use
shouldComponentUpdate is to have it return
false only under certain conditions. If those conditions are met, then your component will not update.
shouldComponentUpdate automatically receives two arguments:
nextState. It's typical to compare
nextState to the current
this.state, and use the results to decide what to do. See how
Example.js does this on lines 8-17.