Course contentsShow
← React
Lesson 234 of 2,3967. Props FundamentalsFree lesson

Inline Arrow Functions vs Stable References

The difference between passing `() => handler()` inline versus passing `handler` directly.

Inline Arrow Functions vs Stable References

What you'll learn: The performance and behavior difference between creating a new function on every render versus reusing the same function reference.

The Two Ways to Pass Functions

When passing a callback to a child component, you have two choices:

Inline arrow function:

<Button onClick={() => handleClick(id)} />

Stable reference:

<Button onClick={handleClick} />

Both work, but they behave differently under the hood.

What Happens on Every Render

Every time your component re-renders, the inline arrow function creates a brand new function. It's a different object in memory each time, even though the code inside looks identical.

Passing handleClick directly, however, references the same function across renders—a stable reference.

Why This Matters

If the child component (Button) is checking whether its props have changed (to avoid unnecessary re-renders), an inline arrow function will always look "new" and trigger a re-render, even when nothing meaningful changed.

Analogy: Imagine giving someone directions. Inline functions are like writing new directions on fresh paper every time—even if the route is identical. Stable references are like handing over the same laminated card each time.

When Each Approach Makes Sense

  • Inline arrow functions are convenient when you need to pass arguments: () => handleClick(id)
  • Stable references are better when no arguments are needed: handleClick

Later, you'll learn optimization techniques to make inline functions stable when you need both benefits.

Key Takeaway: Inline arrow functions create new function objects on every render, while passing function references directly keeps the same function identity—this matters for performance optimization and child component re-rendering behavior.