Pure Components
A Pure Component in React is a component that only re-renders when its props or state change.
🧠Why Pure Components are Useful:
-
Optimized Performance: Pure components avoid unnecessary re-renders by implementing shallow comparison on props and state.
-
Automatic Optimization: React performs a shallow comparison of props and state automatically, ensuring that the component only re-renders when there are actual changes.
Example of a Pure Component:
In short:
Pure components are efficient because they only re-render when there is a change in their props or state, optimizing performance in React applications.