import { Canvas, Meta, Story } from "@storybook/addon-docs/blocks"; import { Example } from "./example.stories";
Like useEffect
, but passed function is throttled.
export function useThrottledEffect(
callback: (...args: any[]) => void,
deps: DependencyList,
delay: number,
noTrailing = false
): void;
- callback
(...args: any[]) => void
- Callback like foruseEffect
, but without ability to return a cleanup function. - deps
DependencyList
- Dependencies list that will be passed to underlyinguseEffect
anduseThrottledCallback
. - delay
number
- Throttle delay. - noTrailing
boolean
(default: false) - IfnoTrailing
is true, callback will only execute everydelay
milliseconds, otherwise, callback will be executed once, after the last call.