UNPKG

@geneui/components

Version:

The Gene UI components library designed for BI tools

17 lines (14 loc) 461 B
import { useRef, useCallback } from 'react'; const useThrottle = (callback, delay) => { const ref = useRef(null); return useCallback(function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } clearTimeout(ref.current); ref.current = setTimeout(() => { callback(...args); }, delay); }, [callback, delay]); }; export { useThrottle as default };