import * as React from 'react'; /** * @internal */ export type UseControllableStateOptions = { /** * User-provided default state or initializer, for uncontrolled usage. */ defaultState?: State | (() => State); /** * User-provided controlled state. `undefined` means internal state will be used. */ state: State | undefined; /** * Used as the initial state if `state` and `defaultState` are both `undefined`. * If `undefined` is the correct initial state, pass that here. */ initialState: State; }; /** * @internal * * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook * to manage a value that could be either `controlled` or `uncontrolled`, * such as a checked state or text input string. * * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled` * * @returns an array of the current value and an updater (dispatcher) function. * The updater function is referentially stable (won't change during the component's lifecycle). * It can take either a new value, or a function which is passed the previous value and returns the new value. * * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`. * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state. * */ export declare const useControllableState: (options: UseControllableStateOptions) => [State, React.Dispatch>];