What are Pure Components in React-JS ?

Forums ReactWhat are Pure Components in React-JS ?
Staff asked 8 months ago

Answers (1)

Add Answer
Jaydip Mali Marked As Accepted
Staff answered 8 months ago

Pure components were introduced in React 15.3 version. The React.Component and React.PureComponent differ in the shouldComponentUpdate() React lifecycle method. This method decides the re-rendering of the component by returning a boolean value (true or false). In React.Component, shouldComponentUpdate() method returns true by default. But in React.PureComponent, it compares the changes in state or props to re-render the component. The pure component enhances the simplicity of the code and the performance of the application.


Select Categories