Skip to content
React PDF Viewer

Search

useControllableState reference

The value / defaultValue / onValueChange pattern as a hook: the one behind every controlled prop of the viewer.

Internal state is used while value is undefined; onChange fires whenever the value changes. The setter is stable. Values must not be functions (a function argument is treated as an updater).

Used by

Import

import { useControllableState } from '@kingtech/react-pdf-viewer';

Signature: useControllableState(options: UseControllableStateOptions<T>): readonly [T, SetControllableState<T>] → readonly [T, SetControllableState<T>]

Options

NameTypeDefaultRequiredDescription
valueT—YesThe controlled value; undefined = uncontrolled.
defaultValueT | () => T—YesInitial value while uncontrolled.
onChange(value: T) => void—NoCalled with every change, controlled or not.
namestring—NoProp name used in development warnings.

Source

packages/react-pdf-viewer/src/hooks/useControllableState.ts

Generated from content/react-pdf-viewer/reference/use-controllable-state.schema.json. Do not edit by hand.