UNPKG

use-lodash-debounce-throttle

Version:

Bring debounce & throttle of lodash version to react-hooks

15 lines (13 loc) 415 B
import { throttle } from 'lodash-es'; import createCancelableHook from './createCancelableHook'; var useDebounce = createCancelableHook(function () { return throttle.apply(void 0, arguments); }, function (wait, options) { var compareParams = [wait]; if (options) { compareParams.push(options.leading); compareParams.push(options.trailing); } return compareParams; }); export default useDebounce;