What is the default implementation for the "shouldComponentUpdate" lifecycle method in React components

No special implementation of the shouldComponentUpdate() method is shouldComponentUpdate() as part of the life cycle of the React component.

I understand that this is a logical function that determines whether render() be called when changes are made to the props and state components, and there are mixins like PureRenderMixin that implements shouldComponentUpdate()

If no custom implementation or mixins are implemented. What is the default implementation and behavior?

+5
source share
2 answers

As with React v0.13 and v0.14, the default implementation is null and according to this logic:

  var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext); 

the component is updated every rendering cycle (since !inst.shouldComponentUpdate evaluates to true ).

+5
source

Given the React Docs documentation, the default value is true :

shouldComponentUpdate () is called before rendering when new properties or states are received. The default value is true.

0
source

Source: https://habr.com/ru/post/1234971/


All Articles