@itwin/core-react
Version:
A react component library of iTwin.js UI general purpose components
22 lines • 941 B
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Utilities
*/
import * as React from "react";
import throttle from "lodash/throttle.js";
const defaultOptions = {
leading: false,
trailing: true,
};
/** Used to throttle function calls
* @internal
*/
export function useThrottledFn(functionToThrottle, waitTime, dependencies, options = defaultOptions) {
const throttledFunction = throttle(functionToThrottle, waitTime, options);
// eslint-disable-next-line react-hooks/exhaustive-deps
return React.useCallback(throttledFunction, dependencies);
}
//# sourceMappingURL=useThrottledFn.js.map