useToggle
Boolean state with a stable action for toggling or setting an explicit value.
useToggle(initialValue?: boolean): readonly [boolean, (next?: ToggleUpdater) => void]Public API / 37 Hooks
Search by behavior, category, or TypeScript signature. Every entry links to its runtime contract and source.
37 API entries found.
Boolean state with a stable action for toggling or setting an explicit value.
useToggle(initialValue?: boolean): readonly [boolean, (next?: ToggleUpdater) => void]Boolean state with named setTrue, setFalse, and toggle actions.
useBoolean(initialValue?: boolean): UseBooleanResultA controlled/uncontrolled state primitive with one stable setter contract.
useControllableState<T>(options?: UseControllableStateOptions<T>): readonly [T | undefined, SetValue<T>]Reads the value from the previous committed render.
usePrevious<T, U = undefined>(value: T, initialValue?: U): T | U | undefinedA stable ref that follows the latest committed value.
useLatest<T>(value: T): RefObject<T>Keeps a stable callback identity while invoking the latest committed implementation.
useMemoizedFn<T extends (...args: never[]) => unknown>(fn: T): TProvides state whose setter ignores updates after the component unmounts.
useSafeState<S>(initialState: S | (() => S)): UseSafeStateResult<S>Adds a stable reset action that restores the first resolved state value.
useResetState<S>(initialState: S | (() => S)): UseResetStateResult<S>Manages a bounded number with stable increment, decrement, set, and reset actions.
useCounter(initialValue?: number, options?: UseCounterOptions): UseCounterResultManages a readonly Map snapshot with stable immutable actions.
useMap<K, V>(initialValue?: MapInitializer<K, V>): UseMapResult<K, V>Manages a readonly Set snapshot with stable membership actions.
useSet<T>(initialValue?: SetInitializer<T>): UseSetResult<T>Publishes a value after it remains unchanged for the configured delay.
useDebounce<T>(value: T, options: DebounceOptions): TLimits value publication to at most once per delay window.
useThrottle<T>(value: T, options: ThrottleOptions): TDebounces function calls with cancel, flush, and pending controls.
useDebounceFn<Args, Result>(fn: (...args: Args) => Result, options: DebounceFnOptions): DebouncedFunction<Args, Result>Throttles function calls while preserving the latest committed callback.
useThrottleFn<Args, Result>(fn: (...args: Args) => Result, options: ThrottleFnOptions): ThrottledFunction<Args, Result>Runs the latest callback once after a delay, with cancellation state.
useTimeout(callback: () => void, delay: number | null, options?: UseTimeoutOptions): { cancel: () => void; pending: boolean }Runs the latest callback on a declarative interval.
useInterval(callback: () => void, delay: number | null, options?: UseIntervalOptions): voidRuns abortable asynchronous work with stale-result protection.
useAsync<T>(task: AsyncTask<T>, options?: UseAsyncOptions): UseAsyncResult<T>Prevents overlapping calls to an async or synchronous action.
useLockFn<Args extends readonly unknown[], Result>(fn: (...args: Args) => Result | PromiseLike<Result>, options?: UseLockFnOptions): LockFn<Args, Awaited<Result>>Manages a browser WebSocket with raw messages, stable actions, and bounded reconnects.
useWebSocket(url: string | URL | null, options?: UseWebSocketOptions): UseWebSocketResultSubscribes to an EventTarget with typed window events and automatic cleanup.
useEventListener(target?, type, listener, options?: UseEventListenerOptions | boolean): voidCalls a handler for pointer presses outside a referenced element.
useClickOutside<T extends HTMLElement>(ref: RefTarget<T>, onOutside: (event: PointerEvent) => void, enabledOrOptions?: boolean | UseClickOutsideOptions): voidSubscribes to a media query through a shared external store.
useMediaQuery(query: string, options?: MediaQueryOptions): booleanTracks viewport dimensions with one shared resize subscription.
useWindowSize(): Readonly<{ width: number; height: number }>Tracks navigator connectivity with one listener pair per browser realm.
useOnline(): booleanTracks document visibility through a shared external-store subscription.
useDocumentVisibility(options?: UseDocumentVisibilityOptions): VisibilityStateMatches key alternatives, predicates, and string chords such as ctrl+s.
useKeyPress(keyFilter: KeyFilter, handler: KeyPressHandler, options?: UseKeyPressOptions): voidTracks mouseenter and mouseleave state for a target and follows ref changes.
useHover(target?: HoverTarget, options?: UseHoverOptions): booleanCopies text with observable status and protection from stale write results.
useCopyToClipboard(options?: UseCopyToClipboardOptions): UseCopyToClipboardResultConnects text inputs to controlled or uncontrolled string state.
useInput(options?: UseInputOptions): UseInputResultSynchronizes typed state with localStorage and reports serialization errors.
useLocalStorage<T>(key: string, initialValue: T | (() => T), options?: StorageOptions<T>): UseStorageResult<T>Synchronizes typed state with sessionStorage for the current tab session.
useSessionStorage<T>(key: string, initialValue: T | (() => T), options?: StorageOptions<T>): UseStorageResult<T>Returns a stable function that reports committed mount state.
useIsMounted(): () => booleanUses useLayoutEffect in the browser and useEffect during SSR.
useIsomorphicLayoutEffect: typeof React.useEffectExposes a stable ref that becomes true during unmount cleanup.
useUnmountedRef(): RefObject<boolean>Tracks intersection state for an element or ref with a deterministic SSR snapshot.
useIntersectionObserver(options?: UseIntersectionObserverOptions): IntersectionObserverState; useIntersectionObserver(target: IntersectionObserverTarget, options?: Omit<UseIntersectionObserverOptions, 'target' | 'ref'>): IntersectionObserverStateTracks an element size through ResizeObserver with stable dimensions and cleanup.
useResizeObserver(options?: UseResizeObserverOptions): ResizeObserverState; useResizeObserver(target: ResizeObserverTarget, options?: Omit<UseResizeObserverOptions, 'target' | 'ref'>): ResizeObserverState