@sberdevices/plasma-temple
Version:
SberDevices CanvasApp Templates.
15 lines (14 loc) • 627 B
JavaScript
import React from 'react';
import throttle from 'lodash.throttle';
export var THROTTLE_WAIT = 450;
export var THROTTLE_PARAMS = {
leading: true,
trailing: false
};
export function useThrottledCallback(fn, dependencies) {
var wait = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : THROTTLE_WAIT;
var params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : THROTTLE_PARAMS;
var throttled = throttle(fn, wait, params); // eslint-disable-next-line react-hooks/exhaustive-deps
return React.useCallback(throttled, dependencies);
}
//# sourceMappingURL=useThrottledCallback.js.map