UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

28 lines (24 loc) 814 B
"use client"; const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs'); const require_ref = require('../../utils/ref.cjs'); let react = require("react"); react = require_rolldown_runtime.__toESM(react); //#region src/hooks/use-interval/index.ts /** * `useInterval` is a custom hook that runs a function at a specified interval. * * @see https://yamada-ui.com/docs/hooks/use-interval */ const useInterval = (callback, delay) => { const callbackRef = require_ref.useCallbackRef(callback); (0, react.useEffect)(() => { let timeoutId = null; if (delay !== null) timeoutId = setInterval(callbackRef, delay); return () => { if (timeoutId) clearInterval(timeoutId); }; }, [delay, callbackRef]); }; //#endregion exports.useInterval = useInterval; //# sourceMappingURL=index.cjs.map