/** * Configuration options for the useDebouncedValue hook */ interface DebouncedValueOptions { /** Debounce delay in milliseconds (default: 500) */ delay?: number; /** * Minimum length required for string values to update debounced state (default: 3). * Only applies to string values. Non-string values always update. */ minLength?: number; } /** * Type definition for the return value of the useDebouncedValue hook */ type DebouncedValue = readonly [ /** * The current value of the debounced state */ value: T, /** * The debounced value that updates after the delay */ debounced: T, /** * Function to update the value */ setValue: (val: T | ((val: T) => T)) => void, /** * Function to force an immediate update of the debounced value */ flush: () => void ]; /** * A hook that debounces a value with optional minimum length constraint for strings. * * @template T - The type of the value being debounced * @param initialValue - The initial value for both the immediate and debounced state (defaults to empty string for type T) * @param delayOrOptions - Either a number (delay in ms) or an options object * * @returns A tuple containing: * - [0] immediateValue: Updates instantly on every change * - [1] debouncedValue: Updates after the delay * - [2] setValue: Function to update the immediate value * - [3] flush: Function to force an immediate update of the debounced value * * @example * // Basic usage with defaults (500ms delay, minLength 3) * const [search, debouncedSearch, setSearch, flush] = useDebouncedValue(""); * * @example * // Custom delay * const [search, debouncedSearch, setSearch] = useDebouncedValue("", 300); * * @example * // With options object * const [search, debouncedSearch, setSearch] = useDebouncedValue("", { * delay: 500, * minLength: 2 * }); * * @example * // With flush for manual search * const SearchComponent = () => { * const [search, debouncedSearch, setSearch, flush] = useDebouncedValue("", 500); * * useEffect(() => { * if (debouncedSearch) { * fetchResults(debouncedSearch); * } * }, [debouncedSearch]); * * const handleManualSearch = () => { * flush(); // Immediately update debounced value * searchAPI(search); * }; * * return ( * <> * setSearch(e.target.value)} /> * * * ); * }; */ export declare function useDebouncedValue(initialValue: T, delayOrOptions?: number | DebouncedValueOptions): DebouncedValue; export {};