Course contentsShow
← React
Lesson 952 of 2,39624. React.memoFree lesson

The Lift Content Up Pattern

Pass expensive child components as children or props to isolate them from parent state changes.

The Lift Content Up Pattern

What you'll learn: How to isolate expensive child components from unnecessary re-renders by passing them as children or props instead of rendering them inline.

The Core Problem

When a parent component's state changes, React re-renders everything defined inside that component's JSX—even parts that don't depend on that state. If you have an expensive child component that doesn't need the parent's state, it re-renders wastefully every time the parent updates.

The Pattern: Pass Components Through Props

Instead of defining child components inside the parent's JSX, render them outside and pass them in as children or explicit props. Since these component elements are created in a parent that doesn't re-render, their references stay stable. The intermediary component can update its own state without re-creating these children.

Think of it like handing a sealed package to a delivery driver. The driver can change routes, stop for gas, or update their GPS—but they never open or remake your package. It arrives untouched.

How It Works

// ❌ Bad: SlowWidget re-renders when count changes
function Dashboard() {
  const [count, setCount] = useState(0);
  return (
    <div>
      <button onClick={() => setCount(count + 1)}>Count: {count}</button>
      <SlowWidget /> {/* Re-renders every time! */}
    </div>
  );
}

// ✅ Good: SlowWidget stays stable
function Dashboard({ children }) {
  const [count, setCount] = useState(0);
  return (
    <div>
      <button onClick={() => setCount(count + 1)}>Count: {count}</button>
      {children} {/* Same reference, no re-render */}
    </div>
  );
}

// Usage:
<Dashboard>
  <SlowWidget />
</Dashboard>

Because <SlowWidget /> is created in the outer scope (before Dashboard runs), its element reference doesn't change when count updates inside Dashboard.

Key Takeaway: Pass expensive components as children or props to isolate them from a parent's state changes—React will skip re-rendering them because their element references remain stable.