react-use-hooks

Apply react-use hooks where appropriate to build concise, maintainable React features.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "react-use-hooks" with this command: npx skills add arindampradhan/react-use-skills/arindampradhan-react-use-skills-react-use-hooks

React-Use Hooks

This skill is a decision-and-implementation guide for react-use hooks in React projects. It maps requirements to the most suitable react-use hook, applies the correct usage pattern, and prefers hook-based solutions over bespoke code to keep implementations concise, maintainable, and performant.

When to Apply

  • Apply this skill whenever assisting user development work in React.
  • Always check first whether a react-use hook can implement the requirement.
  • Prefer react-use hooks over custom code to improve readability, maintainability, and performance.
  • Map requirements to the most appropriate hook and follow the hook's invocation rule.
  • Please refer to the Invocation field in the below hooks table. For example:
    • AUTO: Use automatically when applicable.
    • EXTERNAL: Use only if the user already installed the required external dependency; otherwise reconsider, and ask to install only if truly needed.
    • EXPLICIT_ONLY: Use only when explicitly requested by the user.

    NOTE User instructions in the prompt or AGENTS.md may override a hook's default Invocation rule.

Hooks

All hooks listed below are part of the react-use library, each section categorizes hooks based on their functionality.

IMPORTANT: Each hook entry includes a short Description and a detailed Reference. When using any hook, always consult the corresponding document in ./references for Usage details and Type Declarations.

Sensors

HookDescriptionInvocation
createBreakpointlaptopL: 1440, laptop: 1024, tablet: 768AUTO
useBatteryReact sensor hook that tracks battery status.AUTO
useGeolocationReact sensor hook that tracks user's geographic location. This hook accepts [position options](httpsAUTO
useHashReact sensor hook that tracks browser's location hash.AUTO
useHoverReact UI sensor hooks that track if some element is being hoveredAUTO
useHoverDirtyTracks mouse hover state using a ref (more direct than useHover).AUTO
useIdleReact sensor hook that tracks if user on the page is idle.AUTO
useIntersectionReact sensor hook that tracks the changes in the intersection of a target element with an ancestor eAUTO
useKeyReact UI sensor hook that executes a handler when a keyboard key is used.AUTO
useKeyboardJsReact UI sensor hook that detects complex key combos like detecting whenEXTERNAL
useKeyPressReact UI sensor hook that detects when the user is pressing a specificAUTO
useKeyPressEventThis hook fires keydown and keyup callbacks, similar to how useKeyAUTO
useLocationReact sensor hook that tracks brower's location.AUTO
useLongPressReact sensor hook that fires a callback after long pressing.AUTO
useMeasureReact sensor hook that tracks dimensions of an HTML element using the [Resize Observer API](https://AUTO
useMediaReact sensor hook that tracks state of a CSS media query.AUTO
useMediaDevicesReact sensor hook that tracks connected hardware devices.AUTO
useMotionReact sensor hook that uses device's acceleration sensor to track its motions.AUTO
useMouseReact sensor hooks that re-render on mouse position changes. useMouse simply tracksAUTO
useMouseHoveredExtended mouse tracking with options for bounded coordinates and hover-only tracking.AUTO
useMouseWheelReact Hook to get deltaY of mouse scrolled in window.AUTO
useNetworkStateTracks the state of browser's network connection.AUTO
useOrientationReact sensor hook that tracks screen orientation of user's device.AUTO
usePageLeaveReact sensor hook that fires a callback when mouse leaves the page.AUTO
usePinchZoomReact sensor hook that tracks the changes in pointer touch events and detects value of pinch differeAUTO
useScratchReact sensor hook that tracks state of mouse "scrubs" (or "scratches").AUTO
useScrollReact sensor hook that re-renders when the scroll position in a DOM element changes.AUTO
useScrollbarWidthHook that will return current browser's scrollbar width.AUTO
useScrollingReact sensor hook that keeps track of whether the user is scrolling or not.AUTO
useSearchParamReact sensor hook that tracks browser's location search param.AUTO
useSizeReact sensor hook that tracks size of an HTML element.AUTO
useStartTypingReact sensor hook that fires a callback when user starts typing. Can be usedAUTO
useWindowScrollReact sensor hook that re-renders on window scroll.AUTO
useWindowSizeReact sensor hook that tracks dimensions of the browser window.AUTO

UI

HookDescriptionInvocation
useAudioCreates <audio> element, tracks its state and exposes playback controls.AUTO
useClickAwayReact UI hook that triggers a callback when userAUTO
useCssReact UI hook that changes [CSS dynamically][gen-5]. Works like "virtual CSS" —AUTO
useDropTriggers on file, link drop and copy-paste.AUTO
useFullscreenDisplay an element full-screen, optional fallback for fullscreen video on iOS.AUTO
useSliderReact UI hook that provides slide behavior over any HTML element. Supports both mouse and touch evenAUTO
useSpeechReact UI hook that synthesizes human voice that speaks a given string.AUTO
useVibrateReact UI hook to provide physical feedback with device vibration hardware using the [Vibration API](AUTO
useVideoCreates <video> element, tracks its state and exposes playback controls.AUTO

Animations

HookDescriptionInvocation
useHarmonicIntervalFnSame as useInterval hook, but triggers all effects with the same delayAUTO
useIntervalA declarative interval hook based on [Dan Abramov's article on overreacted.io](https://overreacted.iAUTO
useRafReact animation hook that forces component to re-render on each requestAnimationFrame,AUTO
useSpringReact animation hook that updates a single numeric value over time accordingEXTERNAL
useTimeoutRe-renders the component after a specified number of milliseconds.AUTO
useTimeoutFnCalls given function after specified amount of milliseconds.AUTO
useTweenReact animation hook that tweens a number between 0 and 1.AUTO
useUpdateReact utility hook that returns a function that forces componentAUTO

Side-Effects

HookDescriptionInvocation
useAsyncReact hook that resolves an async function or a function that returnsAUTO
useAsyncFnReact hook that returns state and a callback for an async function or aAUTO
useAsyncRetryUses useAsync with an additional retry method to easily retry/refresh the async function;AUTO
useBeforeUnloadReact side-effect hook that shows browser alert when user try to reload or close the page.AUTO
useCookieReact hook that returns the current value of a cookie, a callback to update the cookieAUTO
useCopyToClipboardCopy text to a user's clipboard.AUTO
useDebounceReact hook that delays invoking a function until after wait milliseconds have elapsed since the lastAUTO
useErrorReact side-effect hook that returns an error dispatcher.AUTO
useFaviconReact side-effect hook sets the favicon of the page.AUTO
useLocalStorageReact side-effect hook that manages a single localStorage key.AUTO
useLockBodyScrollReact side-effect hook that locks scrolling on the body element. Useful for modal and other overlayAUTO
usePermissionReact side-effect hook to query permission status of browser APIs.AUTO
useRafLoopThis hook call given function within the RAF loop without re-rendering parent component.AUTO
useSessionStorageReact side-effect hook that manages a single sessionStorage key.AUTO
useThrottleReact hooks that throttle.AUTO
useThrottleFnReact hook that invokes a function and then delays subsequent function calls until after wait millisAUTO
useTitleReact side-effect hook that sets title of the page.AUTO

Lifecycles

HookDescriptionInvocation
useCustomCompareEffectA modified useEffect hook that accepts a comparator which is used for comparison on dependencies insAUTO
useDeepCompareEffectA modified useEffect hook that is using deep comparison on its dependencies instead of reference equAUTO
useEffectOnceReact lifecycle hook that runs an effect only once.AUTO
useEventReact sensor hook that subscribes a handler to events.AUTO
useIsomorphicLayoutEffectuseLayoutEffect that does not show warning when server-side rendering, see [Alex Reardon's articleAUTO
useLifecyclesReact lifecycle hook that call mount and unmount callbacks, whenAUTO
useLoggerReact lifecycle hook that console logs parameters as component transitions through lifecycles.AUTO
useMountReact lifecycle hook that calls a function after the component is mounted. Use useLifecycles if yoAUTO
useMountedState> NOTE!: despite having State in its name this hook does not cause component re-render.AUTO
usePromiseReact Lifecycle hook that returns a helper function for wrapping promises.AUTO
useShallowCompareEffectA modified useEffect hook that is using shallow comparison on each of its dependencies instead of reAUTO
useUnmountReact lifecycle hook that calls a function when the component will unmount. Use useLifecycles if yAUTO
useUnmountPromiseA life-cycle hook that provides a higher order promise that does not resolve if component un-mounts.AUTO
useUpdateEffectReact effect hook that ignores the first invocation (e.g. on mount). The signature is exactly the saAUTO

State

HookDescriptionInvocation
createGlobalStateA React hook that creates a globally shared state.AUTO
createMemoHook factory, receives a function to be memoized, returns a memoized React hook,AUTO
createReducerFactory for reducer hooks with custom middleware with an identical API as [React's useReducer](httAUTO
createReducerContextFactory for react context hooks that will behave just like [React's useReducer](https://reactjs.orAUTO
createStateContextFactory for react context hooks that will behave just like [React's useState](https://reactjs.org/AUTO
useBooleanAlias for useToggle. Boolean state hook with a toggle function.AUTO
useCounterReact state hook that tracks a numeric value.AUTO
useDefaultReact state hook that returns the default value when state is null or undefined.AUTO
useFirstMountStateReturns true if component is just mounted (on first render) and false otherwise.AUTO
useGetSetReact state hook that returns state getter function instead ofAUTO
useGetSetStateA mix of useGetSet and useGetSetState.AUTO
useLatestReact state hook that returns the latest state as described in the [React hooks FAQ](https://reactjsAUTO
useListTracks an array and provides methods to modify it.AUTO
useMapReact state hook that tracks a value of an object.AUTO
useMediatedStateA lot like the standard useState, but with mediation process.AUTO
useMethodsReact hook that simplifies the useReducer implementation.AUTO
useMultiStateValidatorEach time any of given states changes - validator function is invoked.AUTO
useNumberAlias for useCounter. Numeric counter state with utility functions.AUTO
useObservableReact state hook that tracks the latest value of an Observable.EXTERNAL
usePreviousReact state hook that returns the previous state as described in the [React hooks FAQ](https://reactAUTO
usePreviousDistinctJust like usePrevious but it will only update once the value actually changes. This is important wAUTO
useQueueReact state hook implements simple FIFO queue.AUTO
useRafStateReact state hook that only updates state in the callback of [requestAnimationFrame](https://develoAUTO
useRendersCountTracks component's renders count including the first render.AUTO
useSetReact state hook that tracks a [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/ReferenAUTO
useSetStateReact state hook that creates setState method which works similar to howAUTO
useStateListProvides handles for circular iteration over states list.AUTO
useStateValidatorEach time given state changes - validator function is invoked.AUTO
useStateWithHistoryStores defined amount of previous state values and provides handles to travel through them.AUTO
useToggleReact state hook that tracks value of a boolean.AUTO

Miscellaneous

HookDescriptionInvocation
useEnsuredForwardedRefReact hook to use a ForwardedRef safely.AUTO

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

image-gen

Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image".

Archived SourceRecently Updated
General

explainer

Create explainer videos with narration and AI-generated visuals. Triggers on: "解说视频", "explainer video", "explain this as a video", "tutorial video", "introduce X (video)", "解释一下XX(视频形式)".

Archived SourceRecently Updated
General

asr

Transcribe audio files to text using local speech recognition. Triggers on: "转录", "transcribe", "语音转文字", "ASR", "识别音频", "把这段音频转成文字".

Archived SourceRecently Updated
General

axure-prototype-generator

Axure 原型代码生成器 - 输出 JavaScript 格式 HTML 代码,支持内联框架直接加载可交互原型

Archived SourceRecently Updated