UNPKG

web-api-hooks

Version:

Essential set of React Hooks for convenient Web API consumption.

18 lines (17 loc) 685 B
/** * Repeatedly calls a function with a fixed time delay between each call. * * 📝 _Timings may be inherently inaccurate, due to the implementation of [`setInterval`](https://developer.mozilla.org/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) under the hood._ * * @param callback Method to execute periodically. * @param delayMs Time, in milliseconds, to wait between executions of the specified function. Set to `null` for pausing. * * @example * function Component() { * useInterval(() => { * // Custom logic to execute each second * }, 1000); * // ... * } */ export default function useInterval(callback: () => void, delayMs: number | null): void;