Render props is a code-sharing technique in ReactJS. This approach allows for dynamic rendering behaviour by passing the logic and JSX rendering responsibility from the parent component to the child component.
Code sharing
Modularity
Reusability
Decoupling code
Code Encapsulation
For Dynamic rendering behaviour, allowing customization of rendering logic.
For Sharing behaviour or rendering patterns between components.
Encapsulating behaviour that depends on props and state.
Offers great flexibility in customising rendering behaviour.
Encourages component reusability by making components more generic.
Supports sharing behaviour and state between components.
Effective for providing complex UI components that require customization.
It can become verbose when complex logic is passed as render props.
This can lead to a deeper component hierarchy due to multiple layers of render prop components.
Might require passing down multiple render props for different functionalities.
We have a <Hoverable> component that needs to expose its hover state to children. How would you implement this using a render prop?
If you forget to pass a render prop function to a component that expects one, what will happen at runtime?
You need to build a <DataFetcher> component that fetches JSON and lets the caller decide how to render the data. Walk me through how you'd use a render prop for this and why you’d choose it over a higher‑order component.
During a refactor, a component that used a render prop stopped updating when its parent state changed. How would you investigate and fix the issue?
Our UI library has many theming components built with render props, and we’re seeing occasional performance hiccups. How would you profile the impact and decide whether to replace them with hooks or memoization?
Design a reusable <Modal> component that uses a render prop to render its content, supports async close handling, and renders via a portal. What edge cases would you guard against?
The team wants to migrate a large codebase from render‑prop APIs to hook‑based APIs while keeping backward compatibility. How would you plan and execute that migration?
When choosing between render props, higher‑order components, and custom hooks for cross‑cutting concerns, what architectural criteria do you use at a system‑wide level?