memo with Pure Presentational Components
What you'll learn: Why purely presentational components with stable props are the perfect candidates for React.memo.
The Ideal memo Candidate
Purely presentational components are like simple display cases—they show what you give them, nothing more. They receive props, render UI, and have no internal state, side effects, or complex logic. When these components also receive stable props (values that don't change frequently), they become ideal candidates for React.memo.
Why This Combination Works
Think of React.memo as a bouncer checking an ID. For presentational components, the "ID check" (prop comparison) is simple and fast because:
- Predictable output: Same props always produce the same UI
- No hidden complexity: No side effects, context subscriptions, or timers to worry about
- Low comparison cost: Checking a few stable props is cheap
- High skip potential: If parent re-renders frequently but this component's props stay the same, you skip potentially many renders
The Pure Presentational Pattern
A component like a UserAvatar that takes name and avatarUrl is perfect: it displays an image and text, nothing else. When wrapped with memo, it only re-renders when those specific props change—not when its parent's unrelated state updates.
Contrast this with a component that fetches data, manages form state, or subscribes to real-time updates. Those components have internal complexity that makes the memo check less valuable—they'll often re-render anyway due to their own state changes.
Key Takeaway: Pure presentational components with stable props maximize React.memo's benefit-to-cost ratio—the shallow prop comparison is cheap, the render you skip might be expensive, and the behavior remains predictable.