Tracking vs Fixing: When to Act
What you'll learn: How to distinguish between performance issues that need immediate fixing and those that are perfectly acceptable to leave alone.
The Diagnosis vs Treatment Decision
Just because a tool like why-did-you-render reports a re-render doesn't mean you have a problem. Think of it like a smoke detector: it alerts you to smoke, but not all smoke means your house is burning down—sometimes you're just cooking dinner.
When a Re-Render Is Worth Fixing
Act when you observe:
- User-perceptible lag: Typing feels sluggish, scrolling stutters, or interactions feel delayed
- Measurable performance impact: The Profiler shows a commit taking >16ms (causing dropped frames)
- High-frequency cascades: A parent component re-renders 10+ times per second, triggering expensive child tree updates
- Production complaints: Real users report sluggishness in specific workflows
When to Leave It Alone
Don't optimize if:
- The component renders fast: Sub-5ms renders are essentially free, even if they happen frequently
- It's infrequent: A component that re-renders once on route change doesn't need memoization
- No user impact: If users can't perceive the slowness, your time is better spent elsewhere
- The fix adds complexity: Adding
React.memo,useMemo, anduseCallbackeverywhere makes code harder to maintain
The Cost-Benefit Calculation
Every optimization adds cognitive overhead. Reference stability, memoization wrappers, and dependency arrays all require ongoing maintenance. Only pay that cost when the performance gain is measurable and meaningful to users.
Key Takeaway: Track everything to understand your app's behavior, but only fix re-renders that cause measurable user experience degradation—premature optimization adds complexity without benefit.