Skip to main content

React Hooks Reference

v1.0.0

Searchable reference for all React hooks including state, effects, context, and React 19 hooks.

19 entries found

useStateState

useState<S>(initial): [S, Dispatch<S>]

Adds local state to a function component. Returns the current state and a setter function.

const [count, setCount] = useState(0);
useReducerState

useReducer(reducer, init): [state, dispatch]

Alternative to useState for complex state logic. Manages state via a reducer function.

const [state, dispatch] = useReducer(reducer, initialState);
useEffectEffects

useEffect(effect, deps?): void

Runs side effects after render. Pass an empty array to run once on mount only.

useEffect(() => { document.title = title; }, [title]);
useLayoutEffectEffects

useLayoutEffect(effect, deps?): void

Like useEffect but fires synchronously after all DOM mutations — before the browser paints.

useLayoutEffect(() => { ref.current.measure(); }, []);
useInsertionEffectEffects

useInsertionEffect(effect, deps?): void

Fires before any DOM mutations. Meant for CSS-in-JS libraries inserting styles.

useInsertionEffect(() => { injectStyle(css); }, [css]);
useContextContext & Refs

useContext<T>(context): T

Subscribes to the nearest provider of the given context.

const theme = useContext(ThemeContext);
useRefContext & Refs

useRef<T>(initial): MutableRefObject<T>

Returns a mutable ref object that persists across renders. Does not cause re-renders.

const inputRef = useRef<HTMLInputElement>(null);
useImperativeHandleContext & Refs

useImperativeHandle(ref, init, deps?): void

Customises the value exposed to a parent ref via forwardRef.

useImperativeHandle(ref, () => ({ focus: () => inputRef.current?.focus() }));
useMemoPerformance

useMemo<T>(() => T, deps): T

Memoises an expensive computation, re-running only when deps change.

const sorted = useMemo(() => [...list].sort(), [list]);
useCallbackPerformance

useCallback<T>(fn: T, deps): T

Returns a memoised callback. Stable identity unless deps change.

const handleClick = useCallback(() => onClick(id), [id, onClick]);
useTransitionPerformance

useTransition(): [isPending, startTransition]

Marks state updates as non-urgent, keeping the UI responsive.

const [isPending, startTransition] = useTransition();
useDeferredValuePerformance

useDeferredValue<T>(value): T

Defers re-rendering a non-urgent part of the UI.

const deferredQuery = useDeferredValue(searchQuery);
useSyncExternalStoreSynchronisation

useSyncExternalStore(subscribe, getSnapshot): T

Subscribes to an external store in a concurrent-safe way.

const count = useSyncExternalStore(store.subscribe, store.getCount);
useIdSynchronisation

useId(): string

Generates a stable, unique ID safe for server-side rendering.

const id = useId(); // ':r0:'
useDebugValueDebug

useDebugValue(value, format?): void

Displays a label for custom hooks in React DevTools.

useDebugValue(isOnline ? 'Online' : 'Offline');
useReact 19

use(resource): T

Reads a value from a Promise or Context — can be called conditionally.

const user = use(userPromise);
useActionStateReact 19

useActionState(action, init): [state, dispatch]

Manages state derived from a form action (Server Actions).

const [state, action] = useActionState(submitAction, null);
useFormStatusReact 19

useFormStatus(): { pending, data, method, action }

Returns the pending status of the enclosing form submission.

const { pending } = useFormStatus();
useOptimisticReact 19

useOptimistic<T>(state, updater): [T, dispatch]

Displays an optimistic UI state during async operations.

const [optimisticItems, addOptimistic] = useOptimistic(items, (s, n) => [...s, n]);