- The storybook for the current main version can be found at: https://yobgob.github.io/too-many-hooks
- Storybooks will also be build and deployed for each PR at
https://yobgob.github.io/too-many-hooks/pr-preview/pr-[PR number]
Peer dependencies:
bun install @yobgob/too-many-hooks
- Simplifies commonly repeated React code
- Small bundle size
- Bundled with Vite so you get only what you use
Available hooks and a short summary of their purpose:
useArray
- Simplify array state management with useful utilitiesuseFlag
- Simply manage boolean stateuseForm
- Manage state, validations, and submission for forms with any number of dimensionsuseGraph
- Easily manage state with any number of dimensionsuseTally
- Increment and decrement numeric state
useMatchMedia
- Watch for if the window matches a media queryuseMutationObserver
- Observe a Node and rerender on mutations + get mutation informationuseResizeObserver
- Observe an Element and rerender on resizes + get size informationuseWindowListener
- Easily add and remove listeners on the window
useFlexCorners
- Dynamically find corners in items wrapped with flex
useDeepCompareEffect
- Run function when dependencies change, checked deeply for equalityuseThrottleFunction
- Run a function when its args change up to a maximum number of calls per time period in msuseThrottleValue
- Reduce frequency of state updates on a variable to a maximum number of updates per time period in ms
Graph
- A class that supports the storage, access, and manipulation of data with any number of dimensions
- There should be one obvious way to do each thing
- Explicit is better than implicit
- Code should be extensible but not unopinionated
The monorepo contains both the too-many-hooks
library and the storybook for testing and demoing hooks. Contributions will usually include changes to both apps.
To ensure code quality, PRs are automatically linted and checked for adherence to formatting rules before merging. These checks are performed by GitHub workflows at /.github/workflow/lint-and-build-package.yml
and /.github/workflow/lint-and-build-storybook.yml
. Each app also has their own scripts for formatting and linting locally.
Anyone is welcome to contribute! See the contribution guide for details on getting started!