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.
Common patterns:
- (1) State + Actions — return state and handlers together.
- (2) Observer — subscribe/unsubscribe to external sources.
- (3) Factory — accept config to produce different hook instances.
- (4) Composition — call multiple smaller hooks internally.
- (5) Bridge — connect an external library to the React world.
usehooks.com is a great reference for well-tested implementations.