import { SetStateAction, Dispatch } from 'react'; /** * Props for the useOptionallyControlledState hook */ type UseOptionallyControlledStateProps = { /** * The controlled value of the state. * When provided, the component becomes controlled. */ controlledValue?: T; /** * The default value of the state. * Used when the component is uncontrolled. */ defaultValue?: T; /** * A function that is called when the value changes. * @param value The new value */ onChange?: (value: T) => void; }; /** * Custom hook for managing optionally controlled state. * * Features: * - Supports both controlled and uncontrolled state management * - Automatically switches between controlled and uncontrolled modes * - Provides consistent API regardless of control mode * - Handles onChange callbacks for both modes * - Uses useCallback for optimized setter function * - Supports generic types for flexible state values * * @param props - Configuration object containing controlled value, default value, and onChange callback * @returns Tuple containing current value and setter function */ /** * Custom hook that manages state that can be either controlled or uncontrolled. * * This hook provides a unified interface for managing component state that can be * controlled externally or managed internally. It automatically detects whether * the component should be controlled based on the presence of a controlledValue. * * @param controlledValue - The controlled value (makes component controlled when provided) * @param defaultValue - The default value for uncontrolled mode * @param onChange - Callback function called when the value changes * @returns Tuple containing the current value and a setter function * * @example * const [value, setValue] = useOptionallyControlledState({ * controlledValue: props.value, * defaultValue: 0, * onChange: props.onChange * }); */ export declare function useOptionallyControlledState({ controlledValue, defaultValue, onChange, }: UseOptionallyControlledStateProps): [ T, Dispatch> ]; export {};