Nâng CaoReact iconReact

Patterns hay được dùng trong custom hooks là gì?

Các patterns phổ biến:

  • (1) State + Actions pattern: return state và handlers.
  • (2) Observer pattern: subscribe/unsubscribe.
  • (3) Factory pattern: nhận config tạo ra hook instance khác nhau.
  • (4) Composition: gọi nhiều hooks nhỏ bên trong.
  • (5) Bridge pattern: kết nối external library với React world.

usehooks.com là nguồn tham khảo tốt.

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

Mở danh sách React