Mandatory update is not restricted by the valve shouldComponentUpdate, because this function is not used.
Parent component render process
componentWillReceiveProps (the hook function that the component will receive new parameters). This hook function will not be triggered when the default parameters are passed in, and will only be triggered when new parameters are passed in.
Component life cycle (old)
In the new version, except for componentWillUnmount, the rest need to be added UNSAFE_
Component life cycle (new)
What is the difference between the old and new life cycles?
In the new life cycle, the 3 hooks with will of the old version were discarded, and 2 hooks were newly proposed.
getDerivedStateFromProps
Static should be added in front of this function because it is static.
The state modified by this hook depends on props at any time, and other functions cannot be modified.
As long as this hook is blocked, all states have to listen to props.
getSnapshotBeforeUpdate works with componentDidUpdate
Use scenarios of getSnapshotBeforeUpdate
Requirement: Make a news scroll box, the newly rendered news is always on it, the scroll bar stops at a position, and the news in this position is fixed and displayed to the user.
First, clarify two concepts: scroolHeight refers to the total height of the current scrolling box, and scrollTop refers to the height of the jump from the bottom of the box .