0
streamich/ react-use
View on GitHubReact Hooks โ ๐
React Hooks โ ๐
useBattery โ tracks device battery state. useGeolocation โ tracks geo location state of user's device. useHover and useHoverDirty โ tracks mouse hover state of some element. useHash โ tracks location hash value. useIdle โ tracks whether user is being inactive.useIntersection โ tracks an HTML element's intersection. useKey, useKeyPress, useKeyboardJs, and useKeyPressEvent โ track keys. useLocation and useSearchParam โ tracks page navigation bar location state.useLongPress โ tracks long press gesture of some element.useMedia โ tracks state of a CSS media query. useMediaDevices โ tracks state of connected hardware devices.useMotion โ tracks state of device's motion sensor.useMouse and useMouseHovered โ tracks state of mouse position. useMouseWheel โ tracks deltaY of scrolled mouse wheel. useNetworkState โ tracks the state of browser's network connection. useOrientation โ tracks state of device's screen orientation.usePageLeave โ triggers when mouse leaves page boundaries.useScratch โ tracks mouse click-and-scrub state.useScroll โ tracks an HTML element's scroll position. useScrolling โ tracks whether HTML element is scrolling.useStartTyping โ detects when user starts typing.useWindowScroll โ tracks Window scroll position. useWindowSize โ tracks Window dimensions. useMeasure and useSize โ tracks an HTML element's dimensions. createBreakpoint โ tracks innerWidthuseScrollbarWidth โ detects browser's native scrollbars width. usePinchZoom โ tracks pointer events to detect pinch zoom in and out status. useAudio โ plays audio and exposes its controls. useClickAway โ triggers callback when user clicks outside target area.useCss โ dynamically adjusts CSS.useDrop and 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. useRaf โ re-renders component on each requestAnimationFrame.useInterval and useHarmonicIntervalFn โ re-renders component on a set interval using setInterval.useSpring โ interpolates number over time according to spring dynamics.useTimeout โ re-renders component after a timeout.useTimeoutFn โ calls given function after a timeout. useTween โ re-renders component, while tweening a number from 0 to 1. useUpdate โ returns a callback, which re-renders component when called.
useAsync, useAsyncFn, and useAsyncRetry โ resolves an async function.useBeforeUnload โ shows browser alert when user try to reload or close the page.useCookie โ provides way to read, update and delete a cookie. useCopyToClipboard โ copies text to clipboard.useDebounce โ debounces a function. useError โ error dispatcher. useFavicon โ sets favicon of the page.useLocalStorage โ manages a value in localStorage.useLockBodyScroll โ lock scrolling of the body element.useRafLoop โ calls given function inside the RAF loop.useSessionStorage โ manages a value in sessionStorage.useThrottle and useThrottleFn โ throttles a function. useTitle โ sets title of the page.usePermission โ query permission status for browser APIs.
useEffectOnce โ a modified useEffect hook that only runs once.useEvent โ subscribe to events.useLifecycles โ calls mount and unmount callbacks.useMountedState and useUnmountPromise โ track if component is mounted.usePromise โ resolves promise only while component is mounted.useLogger โ logs in console as component goes through life-cycles.useMount โ calls mount callbacks.useUnmount โ calls unmount callbacks.useUpdateEffect โ run an effect only on updates.useIsomorphicLayoutEffect โ useLayoutEffect that that works on server.useDeepCompareEffect, useShallowCompareEffect, and useCustomCompareEffect
createMemo โ factory of memoized hooks.createReducer โ factory of reducer hooks with custom middleware.createReducerContext and createStateContext โ factory of hooks for a sharing state between components.useDefault โ returns the default value when state is null or undefined.useGetSet โ returns state getter get() instead of raw state.useGetSetState โ as if useGetSet and useSetState had a baby.useLatest โ returns the latest state or propsusePrevious โ returns the previous state or props. usePreviousDistinct โ like usePrevious but with a predicate to determine if previous should update.useObservable โ tracks latest value of an Observable.useRafState โ creates setState method which only updates after requestAnimationFrame. useSetState โ creates setState method which works like this.setState. useStateList โ circularly iterates over an array. useToggle and useBoolean โ tracks state of a boolean. useCounter and useNumber โ tracks state of a number. useList ~and useUpsert~ โ tracks state of an array. useMap โ tracks state of an object. useSet โ tracks state of a Set. useQueue โ implements simple queue.useStateValidator โ tracks state of an object. useStateWithHistory โ stores previous state values and provides handles to travel through them. useMultiStateValidator โ alike the useStateValidator, but tracks multiple states at a time. useMediatedState โ like the regular useState but with mediation by custom function. useFirstMountState โ check if current render is first. useRendersCount โ count component renders. createGlobalState โ cross component shared state.useMethods โ neat alternative to useReducer. useEnsuredForwardedRef and ensuredForwardRef โ use a React.forwardedRef safely.
No comments yet. Set the tone โ say what you would want to know.