hook-cook-book
hook-cook-book copied to clipboard
A collection of simple solution to complex problems using React Hooks
The Hook Cook Book
Simple Patterns:
- useState with init function
- setState with function
- Toggle reusable custom hook
- Computed values with useMemo
Advanced Patterns:
- Resource fetching
- Easier controlled components
- Throttling with useCallback and useRef
- Custom hook for objects using lodash
- useReducer with action creators
- useState complex object with actions
- Making setInterval declarative (Dan Abramov)
- Composing setters
Complex UI problems:
Pitfalls:
Under the hood:
Contribute
Submit a PR to contribute more examples. Please follow the same format