Render props là technique chia sẻ code giữa components dùng prop là function trả về React element.
- Component nhận function prop gọi nó với internal state/logic:
<Mouse render={({ x, y }) => <Cat x={x} y={y} />} />. - Linh hoạt hơn HOC vì tránh naming collisions.
- Custom hooks giờ thường là giải pháp cleaner hơn.
Render props is a technique for sharing code between components using a prop that is a function returning a React element.
- The component calls the function prop with its internal state or logic:
<Mouse render={({ x, y }) => <Cat x={x} y={y} />} />. - It is more flexible than HOCs because it avoids naming collisions.
- Custom hooks are now generally the cleaner alternative.