UNPKG

rooks

Version:

Collection of awesome react hooks

28 lines (27 loc) 979 B
import { type DependencyList, type EffectCallback } from "react"; import { type DebounceSettings } from "./useDebounce"; /** * useDebouncedEffect * @description A version of useEffect that debounces the effect execution based on dependency changes * @param effect The effect callback to run (can return a cleanup function) * @param deps The dependency list that triggers the effect * @param delay The debounce delay in milliseconds * @param options Optional debounce settings (leading, trailing, maxWait) * @see https://rooks.vercel.app/docs/hooks/useDebouncedEffect * @example * ```jsx * useDebouncedEffect( * () => { * console.log('Search query:', searchQuery); * // Perform API call * return () => { * // Cleanup * }; * }, * [searchQuery], * 500 * ); * ``` */ declare function useDebouncedEffect(effect: EffectCallback, deps: DependencyList, delay?: number, options?: DebounceSettings): void; export { useDebouncedEffect };