When React.memo Actually Matters
What you'll learn: How to distinguish between performance problems React.memo genuinely solves and expensive premature optimization that clutters your code.
The Core Principle
React.memo prevents a component from re-rendering when its props haven't changed. But wrapping every component in React.memo is cargo-cult programming. The critical question is: does this component's re-render cost enough to justify the memoization overhead?
Memoization itself has costs: React must compare props on every parent render, and you must maintain stable references (with useMemo/useCallback). This adds complexity and cognitive load.
When It Actually Matters
Measurable benefit scenarios:
- Heavy component trees - A component that renders dozens or hundreds of children
- Expensive render logic - Components with complex calculations, heavy string processing, or canvas operations
- High-frequency updates - A parent that updates rapidly (animations, scroll handlers) but the child's props rarely change
- List items with stable data - Rendering large lists where most items don't change between renders
When It's Premature Optimization
- Simple presentational components (buttons, labels, cards)
- Components that always receive new props anyway
- When you haven't profiled and confirmed a problem exists
- When the parent rarely re-renders
The Decision Framework
- Profile first with React DevTools
- Identify components with high render frequency and non-trivial render time
- Apply
React.memoonly to those components - Confirm improvement with another profile
Key Takeaway: React.memo is a scalpel for specific performance bottlenecks identified through profiling, not a blanket solution to sprinkle everywhere. Optimize components that are slow and render often—ignore the rest.