Course contentsShow
← React
Lesson 284 of 2,3968. Props PatternsFree lesson

Render Props vs Hooks: The Modern Tradeoff

Why custom hooks replaced most render prop use cases and when render props still have advantages.

Render Props vs Hooks: The Modern Tradeoff

You'll learn why custom hooks have largely replaced render props and when render props still shine.

The Great Shift

When React introduced hooks in version 16.8, it fundamentally changed how we share stateful logic. Before hooks, render props were the go-to pattern for reusing component logic (along with higher-order components). Now, custom hooks handle 90% of the use cases that render props used to solve — but with cleaner syntax and better composition.

Why Hooks Won

Render props required wrapper components, nested JSX, and explicit prop passing. Custom hooks extract the same logic but return values directly, eliminating "wrapper hell":

Before (Render Props): Nest components, pass functions, manage JSX structure.

After (Hooks): Call a function, get values, use them directly in your component.

Hooks are also easier to compose — you can call multiple custom hooks in sequence without nesting. They avoid the indentation pyramid that render props create when you need several reusable behaviors.

When Render Props Still Matter

Render props haven't disappeared entirely. They excel when:

  1. You need control over rendering location — the parent component decides where to render the shared UI, not just what data to use
  2. The reusable logic is tightly coupled to JSX structure — like virtualization libraries that must control scroll containers
  3. You're building library code where consumers need maximum flexibility in rendering

Think of render props as "inversion of control" — the child tells the parent what to render but not where.

The Modern Default

Start with custom hooks for logic reuse. Reach for render props only when you specifically need the rendering flexibility or are building highly flexible library components.

Key Takeaway: Custom hooks replaced render props for most stateful logic reuse because they're simpler and compose better, but render props remain valuable when you need fine-grained control over where and how shared UI renders.