All Projects → react-hookz → web

react-hookz / web

Licence: MIT license
React hooks done right, for browser and SSR.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to web

useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (-81.28%)
Mutual labels:  hook, react-hooks, react-hook
usehooks-ts
React hook library, ready to use, written in Typescript.
Stars: ✭ 2,873 (+205.64%)
Mutual labels:  hook, react-hooks, react-hook
ReSift
A state management library for data fetches in React
Stars: ✭ 39 (-95.85%)
Mutual labels:  hook, react-hooks
react-ui-hooks
🧩Simple repository of React hooks for building UI components
Stars: ✭ 20 (-97.87%)
Mutual labels:  hook, react-hooks
react-hook-layout
Layouts in React.
Stars: ✭ 16 (-98.3%)
Mutual labels:  hook, react-hooks
Use Http
🐶 React hook for making isomorphic http requests
Stars: ✭ 2,066 (+119.79%)
Mutual labels:  react-hooks, react-hook
react-hook-videojs
Easy React integration of Video.js using hooks.
Stars: ✭ 37 (-96.06%)
Mutual labels:  hook, react-hooks
use-prefers-color-scheme
🪝 React hook for subscribing to user's color scheme preference.
Stars: ✭ 28 (-97.02%)
Mutual labels:  hook, react-hook
react-hooks
🎣 React Hooks to get hooked on
Stars: ✭ 53 (-94.36%)
Mutual labels:  react-hooks, react-hook
window-scroll-position
React hook for Window scroll position
Stars: ✭ 81 (-91.38%)
Mutual labels:  hook, react-hooks
formalizer
React hooks based form validation made for humans.
Stars: ✭ 12 (-98.72%)
Mutual labels:  hook, react-hooks
use-dencrypt-effect
⚛ A custom React hook generating crypting text effect.
Stars: ✭ 39 (-95.85%)
Mutual labels:  hook, react-hooks
react-hubspot
A collection of React hooks for interacting with Hubspot APIs
Stars: ✭ 20 (-97.87%)
Mutual labels:  react-hooks, react-hook
style-hook
use css in js with react hook.
Stars: ✭ 16 (-98.3%)
Mutual labels:  react-hooks, react-hook
react-use-comlink
Three ways to use Comlink web workers through React Hooks (and in a typesafe manner).
Stars: ✭ 39 (-95.85%)
Mutual labels:  react-hooks, react-hook
react-use-hotkeys
React hook for creating simple keyboard shortcuts
Stars: ✭ 74 (-92.13%)
Mutual labels:  hook, react-hooks
use-key-hook
React hook to handle all the key press.
Stars: ✭ 27 (-97.13%)
Mutual labels:  react-hooks, react-hook
use-algolia
Dead-simple React hook to make Algolia search queries. Supports pagination out of the box.
Stars: ✭ 29 (-96.91%)
Mutual labels:  react-hooks, react-hook
use-route-as-state
Use React Router route and query string as component state
Stars: ✭ 37 (-96.06%)
Mutual labels:  hook, react-hooks
Fre
👻 Tiny Footprint Concurrent UI library for Fiber.
Stars: ✭ 3,195 (+239.89%)
Mutual labels:  hook, react-hooks

@react-hookz/web

NPM Version NPM Downloads NPM Dependents Build Coverage Types Tree Shaking

× DOCS × DISCORD × CHANGELOG ×


@react-hookz/web is a library of general-purpose React hooks built with care and SSR compatibility in mind.

Install

This one is pretty simple, everyone knows what to do:

npm i @react-hookz/web
# or
yarn add @react-hookz/web

As hooks was introduced to the world in React 16.8, @react-hookz/web requires - you guessed it - react and react-dom 16.8+. Also, as React does not support IE, @react-hookz/web don't either.

Usage

This package distributed with ESNext language level and both, CJS and ES imports.
It means that depending on your browser target you might need to transpile it. Every major bundler provides a way to transpile node_modules fully or partially. Address your bundler documentation for more details.

You can import hooks two ways:

// from the root of package
import { useMountEffect } from '@react-hookz/web';
// or single hook directly
import { useMountEffect } from '@react-hookz/web/esm/useMountEffect';

In case your bundler supports tree-shaking (most of modern does) - both variants are equal and only necessary code will get into your bundle. Direct hook imports should be considered otherwise.
In case, for some reason, you are not able to use ES imports - you should direct-import hooks from @react-hookz/web/esm folder.

Migrating from react-use

@react-hookz/web was built as a spiritual successor of react-use by one of its former maintainers.

Coming from react-use? Check out our migration guide.

Hooks list

  • Callback

  • Lifecycle

  • State

    • useControlledRerenderState — Like useState, but its state setter accepts an extra argument, that allows cancelling renders.
    • useCounter — Tracks a numeric value and offers functions for manipulating it.
    • useDebouncedState — Like useSafeState but its state setter is debounced.
    • useFunctionalState — Like useState but instead of raw state, a state getter function is returned.
    • useList — Tracks a list and offers functions for manipulating it.
    • useMap — Tracks the state of a Map.
    • useMediatedState — Like useState, but every value set is passed through a mediator function.
    • usePrevious — Returns the value passed to the hook on previous render.
    • usePreviousDistinct — Returns the most recent distinct value passed to the hook on previous renders.
    • useQueue — A state hook implementing FIFO queue.
    • useRafState — Like React.useState, but state is only updated within animation frame.
    • useRenderCount — Tracks component's render count including first render.
    • useSafeState — Like useState, but its state setter is guarded against setting the state of an unmounted component.
    • useSet — Tracks the state of a Set.
    • useToggle — Like useState, but can only be true or false.
    • useThrottledState — Like useSafeState but its state setter is throttled.
    • useValidator — Performs validation when any of the provided dependencies change.
  • Navigator

    • useNetworkState — Tracks the state of the browser's network connection.
    • useVibrate — Provides vibration feedback using the Vibration API.
    • usePermission — Tracks the state of a permission.
  • Miscellaneous

    • useSyncedRef — Like useRef, but it returns an immutable ref that contains the actual value.
    • useCustomCompareMemo — Like useMemo but uses provided comparator function to validate dependency changes.
    • useDeepCompareMemo — Like useMemo but uses @react-hookz/deep-equal comparator function to validate deep dependency changes.
    • useHookableRef — Like useRef but it is possible to define handlers for getting and setting the value.
  • Side-effect

  • Sensor

    • useIntersectionObserver — Observe changes in the intersection of a target element with an ancestor element or with the viewport.
    • useMeasure — Uses ResizeObserver to track an element's dimensions and to re-render the component when they change.
    • useMediaQuery — Tracks the state of a CSS media query.
    • useResizeObserver — Invokes a callback whenever ResizeObserver detects a change to the target's size.
    • useScreenOrientation — Checks if the screen is in portrait or landscape orientation and automatically re-renders on orientation change.
    • useDocumentVisibility — Tracks document visibility state.
  • Dom

    • useClickOutside — Triggers a callback when the user clicks outside a target element.
    • useEventListener — Subscribes an event listener to a target element.
    • useKeyboardEvent — Invokes a callback when a keyboard event occurs on the chosen target.
    • useWindowSize — Tracks the inner dimensions of the browser window.

Contributors

xobotyi
Anton Zinovyev
JoeDuncko
Joe Duncko
ArttuOll
Arttu Olli
kylemh
Kyle Holmberg
AndreasNel
Andreas Nel
Rey-Wang
Rey Wang
wesgro
Jake Ketcheson
axelboc
Axel Bocciarelli
lensbart
Bart Lens
birant
Birant İyigün
punkle
Brian Fletcher
ChloeMouret
Null
dantman
Daniel Friesen
JoshuaStewartEntelect
Joshua Stewart
jpwallace22
Justin Wallace
KonradLinkowski
Konrad Linkowski
MichalTarasiuk
Michał Tarasiuk
Myzel394
Null
fengkx
Fengkx
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].