Our goal with @react-hookz/web is to give the react community a general-purpose React hooks library built with care.
We'd like to port the remaining hooks from react-use (the project @react-hookz/web grew out of) while keeping in mind our tenants:
- General-purposeness (hooks should fulfill a wide array of use cases)
- Composability (a preference for hooks that are useful for building other hooks)
- No or very few dependencies
- SSR compatibility
- 100% test coverage (ideally)
- Concrete example use cases
Hooks to port
Sensors
UI
Animations
Side-effects
Lifecycles
State
Miscellaneous
Join our community!
Have a question? Create a discussion on GitHub or join our Discord community.
Interested in contributing code? Check out our contribution guide. We are excited to see your pull request!
Our goal with
@react-hookz/webis to give the react community a general-purpose React hooks library built with care.We'd like to port the remaining hooks from react-use (the project
@react-hookz/webgrew out of) while keeping in mind our tenants:Hooks to port
Sensors
useHash — tracks location hash value.(No plans to implement. Instead, use one the various routing libraries available.)useKey — track keys.(Implemented as useKeyboardEvent)useKeyPress — track keys.(Implemented as useKeyboardEvent)useKeyboardJs — track keys.(Implemented as useKeyboardEvent)useKeyPressEvent — track keys.(Implemented as useKeyboardEvent)useLocation — tracks page navigation bar location state.(No plans to implement. Instead, use one the various routing libraries available.)useSearchParam — tracks page navigation bar location state.(No plans to implement. Instead, use one the various routing libraries available.)useSize — tracks an HTML element's dimensions.(UseuseWindowSizeinstead)createBreakpoint — tracks innerWidth(Not planning to implement)UI
Animations
useInterval and useHarmonicIntervalFn — re-renders component on a set interval using setInterval.(Implemented asuseIntervalEffect).useTimeout — re-renders component after a timeout.(Can be composed from other hooks, see migration guide).useTimeoutFn — calls given function after a timeout.(Implemented asuseTimeoutEffect).Side-effects
useBeforeUnload — shows browser alert when user try to reload or close the page.(No plans to implement, address migration guide for workaround)useCopyToClipboard — copies text to clipboard.(no plans to implement - use browser's API instead)useFavicon — sets favicon of the page.(Hooks that modify the element will not be implemented).useThrottleFn — throttles a function.useTitle — sets title of the page.(Hooks that modify the element will not be implemented).Lifecycles
useEffectOnce — a modified useEffect hook that only runs once.(it's just an alias foruseMountEffect)useLifecycles — calls mount and unmount callbacks.(no sense to port, has almost no benefit comparing touseEffect)useUnmountPromise — track if component is mounted.(No plans to implement).usePromise — resolves promise only while component is mounted.(No plans to implement)useLogger — logs in console as component goes through life-cycles.(Implemented as useLifecycleLoggerState
createMemo — factory of memoized hooks.(Not planning to implement)createReducer — factory of reducer hooks with custom middleware.(Not planning to implement)createReducerContext — factory of hooks for a sharing state between components.(Not planning to implement)createStateContext — factory of hooks for a sharing state between components.(Not planning to implement)useDefault — returns the default value when state is null or undefined.(No plans to implement. Use useMediatedState instead).useGetSet — returns state getter get() instead of raw state.(No plans to implement)useGetSetState — as if useGetSet and useSetState had a baby.(No plans to implement)useSetState — creates setState method which works like this.setState.(No plans to implement)useNumber — tracks state of a number.(Implemented as useCounter)useUpsert — tracks state of an array.(UseuseListinstead.)useRendersCount — count component renders.(Implemented asuseRenderCount).createGlobalState — cross component shared state.(Not planning to implement)useMethods — neat alternative to useReducer.(No plans to implement)Miscellaneous
Join our community!
Have a question? Create a discussion on GitHub or join our Discord community.
Interested in contributing code? Check out our contribution guide. We are excited to see your pull request!