Identifying Object Creation in Props
What you'll learn: How to spot inline object/array creation in JSX props that triggers unnecessary child re-renders.
The Pattern That Hurts Performance
Every time you write <Child style={{ color: 'red' }} /> or <Child config={{ max: 10 }} />, you're creating a brand new object on every parent render. Even if the values inside stay identical, JavaScript sees these as different objects due to reference inequality.
This matters because React compares props by reference. When Child receives a "new" object (even with identical contents), it assumes something changed and re-renders—even if you've wrapped it in React.memo.
Common Culprits to Watch For
Look for these patterns in your JSX:
// ❌ New object every render
<UserCard style={{ padding: 10 }} />
// ❌ New array every render
<List items={[item1, item2]} />
// ❌ New object with computed values
<Chart config={{ min: 0, max: data.length }} />
// ❌ Multiple inline objects
<Modal style={{ width: 500 }} options={{ closeOnEsc: true }} />
Think of it like giving someone a new gift-wrapped box every second, even though the same toy is inside. They keep unwrapping (re-rendering) because they can't tell without looking that it's the same gift.
How to Spot Them
When profiling, if you see a component re-rendering only because its parent rendered, check its props in the Profiler. Look for object/array props that have the same content but different references each time.
Key Takeaway: Inline object/array literals in JSX (style={{...}}, config={{...}}, items={[...]}) create new references every render, forcing child components to re-render even when the actual data hasn't changed.