https://github.com/500tech/hook-cook-book
A collection of simple solution to complex problems using React Hooks
https://github.com/500tech/hook-cook-book
Last synced: 5 months ago
JSON representation
A collection of simple solution to complex problems using React Hooks
- Host: GitHub
- URL: https://github.com/500tech/hook-cook-book
- Owner: 500tech
- Created: 2019-02-01T09:31:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-13T13:12:13.000Z (over 6 years ago)
- Last Synced: 2025-04-30T10:33:30.935Z (about 1 year ago)
- Homepage:
- Size: 11.7 KB
- Stars: 30
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The Hook Cook Book
Simple Patterns:
- [useState with init function](https://codesandbox.io/s/92r9yrmnyo)
- [setState with function](https://codesandbox.io/s/w6xynq3z9l)
- [Toggle reusable custom hook](https://codesandbox.io/s/zrjn39qqwx)
- [Computed values with useMemo](https://codesandbox.io/s/v80068jq40)
Advanced Patterns:
- [Resource fetching](https://codesandbox.io/s/9z4l2po0pw)
- [Easier controlled components](https://codesandbox.io/s/o97l3qzq5z)
- [Throttling with useCallback and useRef](https://codesandbox.io/s/qq8rl8lx96)
- [Custom hook for objects using lodash](https://codesandbox.io/s/v618v21x5y)
- [useReducer with action creators](https://codesandbox.io/s/rrryqpwovq)
- [useState complex object with actions](https://codesandbox.io/s/61qw22lp3z)
- [Making setInterval declarative (Dan Abramov)](https://codesandbox.io/s/105x531vkq)
- [Composing setters](https://codesandbox.io/s/composing-state-setters-g6kmq)
Complex UI problems:
- [Virtual scroll](https://codesandbox.io/s/214p1911yn)
- [Drag and Drop](https://codesandbox.io/s/v3x74022j5)
- [Scroll tracking with a reusable custom hook](https://codesandbox.io/s/r5r7w0697q)
Pitfalls:
- [Stale state with useCallback](https://codesandbox.io/s/p55wln789x)
Under the hood:
- [Order of effects, layout effects, and renders](https://codesandbox.io/s/rj6m9w531p)
### Contribute
Submit a PR to contribute more examples. Please follow the same format