Pure components were introduced in React 15.3. React.Component
and React.PureComponent
differ in implementing the shouldComponentUpdate()
lifecycle method. The shouldComponentUpdate()
method decides the re-rendering of the component by returning a boolean. In React.Component
, it returns true by default. But in pure components, shouldComponentUpdate()
compares if there are any changes in state or props to re-render the component.
Here I am sharing my observations about how unnecessary renders are reduced by the pure component.