Reading the Console Output
What you'll learn: How to interpret the detailed console logs that why-did-you-render produces to pinpoint exactly which props or hooks caused unnecessary re-renders.
Understanding the Console Message
When why-did-you-render detects an unnecessary render, it logs a detailed message to your browser console. This isn't just a vague warning—it's a diagnostic report showing you exactly what changed between renders.
The output typically shows:
- Component name that re-rendered unnecessarily
- Reason for re-render (props change, hook change, or parent render)
- Which specific props or hooks changed, even if the values are deeply equal
- Before and after values so you can see if they're referentially different but structurally identical
What to Look For
The key insight is spotting reference inequality. The console might show something like:
MyComponent re-rendered because of prop changes:
• items: {} !== {} (referentially different)
This tells you that items was recreated (new object/array/function reference) even though its contents are identical. It's like getting a new grocery list with the exact same items written on it—technically different paper, same shopping trip.
Similarly, hook changes might reveal:
Different hooks detected:
• prev useCallback hook !== new useCallback hook
This means a useCallback or useMemo dependency changed, causing a new reference.
The Diagnosis Path
Read the output methodically: component name → trigger (prop/hook) → specific culprit. This tells you where to apply optimization (memoization, stable references) upstream in the parent component.
Key Takeaway: The why-did-you-render console output is your performance X-ray—it reveals the exact props or hooks causing unnecessary renders by showing referential differences between render cycles.