UNPKG

@yamada-ui/react

Version:

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

27 lines (23 loc) 670 B
"use client"; import { useCallbackRef } from "../../utils/ref.js"; import { useEffect } from "react"; //#region src/hooks/use-timeout/index.ts /** * `useTimeout` is a custom hook that executes a function after a specified number of milliseconds. * * @see https://yamada-ui.com/docs/hooks/use-timeout */ const useTimeout = (callback, delay) => { const callbackRef = useCallbackRef(callback); useEffect(() => { if (delay == null) return void 0; let timeoutId = null; timeoutId = setTimeout(callbackRef, delay); return () => { clearTimeout(timeoutId); }; }, [delay, callbackRef]); }; //#endregion export { useTimeout }; //# sourceMappingURL=index.js.map