What is a React Pure Component ?
If React components render()
function renders the same result given the same
props and state , you can use PureComponent
for a performance boost.
PureComponent
’s shouldComponentUpdate()
function only shallow compares the objects.
Also its skips prop updates for the whole component subtree. So need to make
sure that all the children components are also “pure”.
Best use case for PureComponent
are presentational components which have no
child components and no dependencies on the global state in the application.
References
Categories :
React
JavaScript