Course contentsShow
← React
Lesson 903 of 2,39623. useMemo and useCallbackFree lesson

When Referential Stability Doesn't Matter

Identifying cases where new references are harmless: non-memoized children, non-dependency props, and render-only values.

When Referential Stability Doesn't Matter

You'll learn: Not every new reference causes problems — sometimes changing references are completely harmless.

The Over-Optimization Trap

You've learned about useMemo and useCallback to maintain referential stability, but here's the truth: most of the time, new references don't matter at all. Understanding when stability doesn't matter saves you from unnecessary memoization code.

Three Safe Scenarios

1. Non-Memoized Children

If a child component isn't wrapped in React.memo, it re-renders whenever its parent does anyway. Passing a new object or function reference doesn't change that behavior:

function Parent() {
  const config = { theme: 'dark' }; // New object every render
  return <Child config={config} />; // Child isn't memoized — doesn't matter!
}

No React.memo means no reference-checking optimization, so the new config is harmless.

2. Non-Dependency Props

Props that aren't used in dependency arrays don't trigger re-runs. If you pass a new function but it's not in a useEffect or useMemo dependency array, changing references are invisible:

function Child({ onClick, data }) {
  useEffect(() => {
    // onClick not used here — its reference doesn't matter
    console.log(data);
  }, [data]); // Only 'data' matters
}

3. Render-Only Values

Values used only for rendering (not in hooks or memoized children) don't care about references:

const styles = { color: 'blue' }; // New object every render
return <div style={styles}>Hello</div>; // Perfectly fine!

React applies the styles regardless — no comparison happens.

When to Skip Memoization

If your value doesn't appear in dependency arrays and isn't passed to memoized components, new references are completely harmless.

Key Takeaway: Only memoize when references cause actual problems — in dependency arrays or props to React.memo components. Otherwise, keep your code simple.