Spotting Reference Inequality in Props
You'll learn how to identify when passing new object, array, or function references as props causes child re-renders even when the data is logically identical.
The Hidden Culprit
You've optimized your component with React.memo(), but it still re-renders unnecessarily. The problem? You're passing props that look the same but have different references. In JavaScript, {} !== {} and [] !== [] — each time the parent renders, it creates brand-new objects, arrays, or functions, even if their contents are identical.
This reference inequality breaks memoization because React's shallow comparison sees "different props" when the reference changes.
What to Look For
In the Profiler's "Why did this render?" section, you'll see:
- "Props changed: config" — but the config object looks identical
- "Props changed: onClick" — an inline arrow function recreated on every render
- "Props changed: items" — an array filtered inline like
items.filter(...)
These are reference inequality issues. The parent component creates a new reference each time, triggering the child to re-render.
Spotting the Pattern
Look at your JSX:
<ExpensiveChild
config={{ theme: 'dark', size: 'large' }} // New object every render!
items={data.filter(x => x.active)} // New array every render!
onClick={() => handleClick(id)} // New function every render!
/>
Each render creates fresh references. Even though the values haven't changed, the identity has — and that's what triggers re-renders.
Key Takeaway: Reference inequality happens when you create new objects, arrays, or functions inline in props. Spot it in the Profiler by checking "why did this render" — if props show as changed but their values are identical, you've found a reference problem that useMemo or useCallback can solve.