React JS - shouldComponentUpdate Life Cycle Method

 












shouldComponentUpdate() method is a unique Life Cycle Method which is called in Updating phase.

We can apply condition on updating state/props.

shouldComponentUpdate() method returns a Boolean Value (true/false). The default value is true

If we set, return value to false, then it will allow component to update until return value is set to true.

It improves application performance / speed.

In the below example, we have applied a condition inside shouldComponentUpdate() method that the component gets updated only when count is between 5 to 10.



















Output :










Comments