How does React handle re-renders, and how can you optimize unnecessary renders?
Understand how React re-renders components and how to prevent wasted renders using memoization and key optimization techniques.
advancedPerformance optimizationreact renderingoptimizationmemoizationreconciliation
Published: 10/26/2025
Updated: 10/26/2025
React re-renders a component whenever its state or props change.
However, unnecessary re-renders can slow down performance if not managed carefully.
⚙️ Example of Unnecessary Renders
function Parent({ count }) {
return (
<>
<Child />
<span>{count}</span>
</>
);
}
const Child = () => {
console.log('Rendered');
return <div>Child</div>;
};
Even if Child doesn’t depend on count, it re-renders every time.
âś… Optimize using React.memo:
const Child = React.memo(() => <div>Child</div>);
đź’ˇ Optimization Tips
- Use
React.memofor pure components. - Use
useCallbackanduseMemoto prevent prop reference changes. - Keep component trees shallow.
- Avoid anonymous inline functions when possible.
Stay Updated
Get the latest frontend challenges, interview questions and tutorials delivered to your inbox.