Hooks Can't Replace All Render Props Use Cases
You'll learn: Why some scenarios still need render props even in the hooks era.
Hooks have revolutionized how we share stateful logic in React, making most render props patterns obsolete. But there's a crucial limitation: hooks handle logic sharing, not rendering decisions.
The Gap Hooks Can't Fill
Hooks let you extract and reuse stateful behavior, but they can't dynamically decide which component to render or how to render based on runtime conditions in the same flexible way render props can.
Think of it like a restaurant kitchen: hooks are like pre-made sauces you can use anywhere (logic reuse), but render props are like letting the customer choose their plating style at serving time (rendering flexibility).
Scenarios Where Render Props Win
Dynamic Component Selection:
<DataProvider render={(data) => {
// Runtime decision based on data
return data.type === 'chart'
? <Chart data={data} />
: <Table data={data} />;
}} />
A hook can give you data, but it can't decide which component to render with that data—that's a JSX-level decision the parent must make.
Render-Time Flexibility:
<Toggle>
{(isOn, toggle) => (
// Consumer decides entire render structure
isOn ? <FancyModal onClose={toggle} /> : <SimpleButton onClick={toggle} />
)}
</Toggle>
The component using <Toggle> gets to control the complete rendering logic, not just receive state values.
Why This Matters
Hooks extract behavior. Render props delegate rendering authority. When you need the consumer to make compositional decisions—not just use stateful logic—render props remain the right tool.
Key Takeaway: Hooks replace render props for logic sharing, but render props still shine when you need to delegate rendering decisions to the consumer at runtime.