Skip to content

Port remaining hooks from react-use #33

Open
@JoeDuncko

Description

@JoeDuncko

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

  • useAudio — plays audio and exposes its controls.
  • useClickAway — triggers callback when user clicks outside target area. (Implmented as useClickOutside)
  • useCss — dynamically adjusts CSS.
  • useDrop — tracks file, link and copy-paste drops.
  • useDropArea — tracks file, link and copy-paste drops.
  • useFullscreen — display an element or video full-screen.
  • useSlider — provides slide behavior over any HTML element.
  • useSpeech — synthesizes speech from a text string.
  • useVibrate — provide physical feedback using the Vibration API.
  • useVideo — plays video, tracks its state, and exposes playback controls.

Animations

  • useRaf — re-renders component on each requestAnimationFrame.
  • useInterval and useHarmonicIntervalFn — re-renders component on a set interval using setInterval. (Implemented as useIntervalEffect).
  • useSpring — interpolates number over time according to spring dynamics.
  • useTimeout — re-renders component after a timeout. (Can be composed from other hooks, see migration guide).
  • useTimeoutFn — calls given function after a timeout. (Implemented as useTimeoutEffect).
  • useTween — re-renders component, while tweening a number from 0 to 1.
  • useUpdate — returns a callback, which re-renders component when called. (Implemented as useRerender)

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!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions