Why does React rerender a child if its props remain unchanged?

Viewed 1402

The answer from this question makes sense: If the props for a child component are unchanged, does React still re-render it? and I also made a CodePen to verify it.

shouldComponentUpdate(nextProps, nextState) {
  console.log(nextProps.test === this.props.test);
  console.log('shouldComponentUpdate');
  return true;
}

But one statement on React's website is that:

shouldComponentUpdate() is invoked before rendering when new props or state are being received.

But in reality, shouldComponentUpdate() is still invoked even if the props and state for a child component remain unchanged. Is there some mistake in the offical statement, or I have misunderstood it?

1 Answers
Related