UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

22 lines (21 loc) 740 B
import { DependencyList } from 'react'; /** * @name useThrottledEffect * @description - A custom useEffect hook that throttles the effect execution. * The effect will run at most once per every `delay` milliseconds. * * @param {() => void} effect The effect function to run. * @param {DependencyList} deps The dependency array for the effect. * @param {number} delay The throttling delay in milliseconds. * * @example * useThrottledEffect( * () => { * // This effect will run at most once every 200ms when `value` changes * console.log('Throttled effect ran', value); * }, * [value], * 200 * ); */ export declare const useThrottledEffect: (effect: () => void, deps: DependencyList, delay: number) => void;