The Component in React has two problems

  • The component will rerender () even if the state data is not changed as long as setState() is executed
  • When the current component rerenders (), it automatically rerenders the children, which can be inefficient if they don’t use anything from the parent.

Causes of the above problems

  • ShouldComponentUpdate () always returns true

Efficient practice

  • Rerender only if the component’s state or props data changes

The solution to the problem

  1. Determine render by manually judging shouldComponentUpdate

  2. Change Component introduced from React to PureComponent (both parent and child components need to be changed)