Important Considerations
There is also a possibility that these State and Props objects contain nested data structure then Pure Component’s implemented shouldComponentUpdate will return false and will not update the whole subtree of Children of this Class Component. So in Pure Component, the nested data structure doesn’t work properly.
In this case, State and Props Objects should be simple objects and Child Elements should also be Pure, which means to return the same output for the same input values at any instance.
Also, it is important to use immutable data for props and states to ensure the proper functioning of pure components.
ReactJS Pure Components
Generally, In ReactJS, we use the shouldComponentUpdate() Lifecycle method to customize the default behavior and implement it when the React component should re-render or update itself.
When working with React pure components, we can utilize their behavior to optimize behavior as pure components automatically handle the shouldComponentUpdate() method and we don’t need to explicitly implement it.
In this article, we will learn what is Pure component in React, and its key points with examples.