Render Props for Dynamic Rendering Control
You'll learn where render props still shine even in the hooks era—giving consumers full control over what and how to render.
While hooks have largely replaced render props for sharing stateful logic, render props remain uniquely powerful for dynamic rendering control. This is about letting the consumer of your component decide exactly what gets rendered and how it appears, without you hardcoding those decisions.
The Core Idea
Think of render props as a "rendering contract." Your component handles the logic (state, calculations, side effects), but it doesn't dictate the visual output. Instead, it hands the data to a function the consumer provides, saying: "Here's what I know—you decide what to show."
Hooks extract logic beautifully, but they can't delegate rendering decisions back to the consumer. A hook returns data; the component still decides how to render it. A render prop inverts this—your component becomes a logic shell that the consumer fills with their rendering logic.
When This Matters
Use render props when:
- The same logic could render completely different UIs
- You're building a library component that needs maximum flexibility
- The consumer needs precise control over structure, styling, or element types
- You want to avoid bloating your API with dozens of customization props
// Consumer controls EVERYTHING about rendering
<DataFetcher url="/api/users">
{(data, loading) => loading ? <Spinner /> : <UserGrid users={data} />}
</DataFetcher>
// Different consumer, totally different output
<DataFetcher url="/api/users">
{(data, loading) => loading ? "Loading..." : data.map(u => u.name).join(", ")}
</DataFetcher>
The component provides data; consumers render it however they want.
Key Takeaway: Render props excel when you need to hand rendering control to your consumers—hooks share logic, render props share logic and delegate presentation.