UNPKG

@nex-ui/hooks

Version:

A collection of React Hooks for Nex UI components.

15 lines (13 loc) 857 B
/** * A custom React hook that manages a controlled or uncontrolled state value. * * @typeParam T - The type of the state value. * @param value - The controlled value. If provided, the state is controlled. * @param defaultValue - The initial value to use when uncontrolled. * @param onChange - Optional callback invoked when the value changes. * @returns A tuple containing the current value and a function to update it. */ declare function useControlledState<T>(value: T | undefined, defaultValue: T | undefined, onChange?: (v: T) => void): [T, (v: T) => void]; declare function useControlledState<T>(value: T, defaultValue: T | undefined, onChange?: (v: T) => void): [T, (v: T) => void]; declare function useControlledState<T>(value: T | undefined, defaultValue: T, onChange?: (v: T) => void): [T, (v: T) => void]; export { useControlledState };