What problem does it solve?
hooks-patterns helps you write correct React components by explaining the core invariants behind Hooks call order, dependency arrays, effects vs derived logic, and when memoization or custom hooks are truly warranted.
Core Features & Use Cases
- Rules of Hooks as a compile-time invariant: prevents subtle slot-misalignment bugs caused by conditional or improperly nested hook calls.
- Dependency array reasoning: fixes stale-closure, over-firing, and silent exhaustive-deps disables by matching closures to rerenders.
- Effect selection and refactoring: distinguishes synchronization with external systems (effects) from computation during render (derived values).
- Custom hook extraction criteria: guides when reuse, naming, or state-machine encapsulation earns a new hook.
- useMemo/useCallback guardrails: reduces unnecessary overhead and avoids memoization that doesn’t actually protect anything.
- React 18+ semantics coverage: accounts for automatic batching, concurrent rendering, Strict Mode double-invocation, and guidance around useEffectEvent-style separation.
Quick Start
Use hooks-patterns to review a component’s Hooks usage and rewrite the problematic parts so they follow the correct dependency and effect discipline.