UNPKG

594 BTypeScriptView Raw
1export type DispatchStateAction<T> = React.Dispatch<React.SetStateAction<T>>;
2/**
3 * A helper hook for handling controlled and uncontrolled values in a
4 * component's props.
5 *
6 * If the value is uncontrolled, pass `undefined` as `controlledValue` and use
7 * the returned setter to update it.
8 *
9 * If the value is controlled, pass the controlled value as the second argument,
10 * which will always be returned as `value`.
11 *
12 * @template T - The type of the value.
13 */
14export declare function useControlledValue<T>(defaultValue: T, controlledValue: T | undefined): [T, DispatchStateAction<T>];