hooks-belt
Version:
A comprehensive collection of useful React hooks for common use cases
22 lines • 754 B
TypeScript
/**
* A hook that throttles a function execution.
* Ensures the function is called at most once in a specified time period.
*
* @param func - The function to throttle
* @param delay - The throttle delay in milliseconds
* @returns A throttled version of the function
*
* @example
* ```tsx
* const throttledScrollHandler = useThrottle(() => {
* console.log('Scroll event throttled')
* }, 100)
*
* useEffect(() => {
* window.addEventListener('scroll', throttledScrollHandler)
* return () => window.removeEventListener('scroll', throttledScrollHandler)
* }, [throttledScrollHandler])
* ```
*/
export declare function useThrottle<T extends (...args: any[]) => any>(func: T, delay: number): T;
//# sourceMappingURL=useThrottle.d.ts.map