React · Middle · Question 19 of 75
What's the idea of the render props pattern?
- ✓Correct answer: The component calls a passed function to render
- 2The component renders all its props as a string into the DOM
- 3Props are passed only through a class's
render()method
Explanation
<MouseTracker render={pos => <Cursor {...pos} />} /> - the component owns the logic, and the caller decides how to render the result. The function is often passed as children. Hooks largely replaced the pattern, but it remains useful, e.g. in virtualized lists and headless components.