Callback Props with Inline Arrow Functions
What you'll learn: How inline arrow functions in props create new function references on every render and defeat memoization.
The Problem with Inline Arrows
When you pass a callback like onClick={() => handler(id)}, React creates a brand new function on every render. Even if handler and id haven't changed, that arrow function is a different object in memory each time.
For memoized children (React.memo), this is poison. The child receives what looks like the same function, but it's technically a new reference, so the memo check fails and the child re-renders unnecessarily.
// ❌ Creates new function every render
<Child onClick={() => handleClick(item.id)} />
// Child receives different function reference each time
// React.memo can't prevent re-render
Why this happens: Arrow functions are expressions. () => doSomething() creates a new function object every time that line executes, just like { foo: 'bar' } creates a new object.
When It's Actually Acceptable
If the child component isn't memoized or the render is already cheap enough that memoization isn't needed, inline arrows are fine. The "new function" overhead is negligible compared to actual DOM work.
Also acceptable: one-off event handlers in small components where you've profiled and confirmed performance is not an issue.
The problem only matters when you're trying to optimize with React.memo and the inline arrow defeats your optimization.
Key Takeaway: onClick={() => handler(id)} creates a new function on every render, breaking React.memo comparisons—but it's only a problem if you're actually trying to prevent that child from re-rendering.