DEV Community

FatimaAlam1234
FatimaAlam1234

Posted on

React Pure Component

It is used when we want to see a performance boost

Rules ->
Parent Component along with all it's child component should be pure.
There should be no state mutation instead always a new object should be returned.

Advantages ->
It's shdComponentUpdate() value is be default false instead of true as in case of Regular Components.
It does a shallow comparison for both ->
Primitive -> checks value of them and if same doesn't re-render.
Complex -> Objects, arrays, lists -> It checks the reference if same -> doesn't re-render.

Note -> Should mostly use Regular Components unless performance is the issue

Top comments (0)