Mid From PDF React React.js

What are pure components?

Pure Component is a React class component that automatically implements

shouldComponentUpdate with a shallow prop and state comparison.

  • Benefit: It prevents unnecessary re-renders by performing a shallow comparison of

props and state.

Example:

class MyComponent extends React.PureComponent {

render() {

return <div>{this.props.name}</div>;
}
}

Pure components are a good choice when you know that your component only depends on

props and state and you want to avoid unnecessary updates.

More from React.js Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details