UNPKG

896 BTypeScriptView Raw
1/**
2 * Given a prop value and state value, the useControllableProp hook is used to determine whether a component is controlled or uncontrolled, and also returns the computed value.
3 *
4 * @see Docs https://chakra-ui.com/docs/hooks/use-controllable#usecontrollableprop
5 */
6export declare function useControllableProp<T>(prop: T | undefined, state: T): [boolean, T];
7export interface UseControllableStateProps<T> {
8 value?: T;
9 defaultValue?: T | (() => T);
10 onChange?: (value: T) => void;
11 shouldUpdate?: (prev: T, next: T) => boolean;
12}
13/**
14 * The `useControllableState` hook returns the state and function that updates the state, just like React.useState does.
15 *
16 * @see Docs https://chakra-ui.com/docs/hooks/use-controllable#usecontrollablestate
17 */
18export declare function useControllableState<T>(props: UseControllableStateProps<T>): [T, React.Dispatch<React.SetStateAction<T>>];