Trung BìnhReact iconReact

Render props pattern là gì?

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.

Xem toàn bộ React cùng filter theo level & chủ đề con.

Mở danh sách React