@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
29 lines (25 loc) • 828 B
JavaScript
"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-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 = require_ref.useCallbackRef(callback);
(0, react.useEffect)(() => {
if (delay == null) return void 0;
let timeoutId = null;
timeoutId = setTimeout(callbackRef, delay);
return () => {
clearTimeout(timeoutId);
};
}, [delay, callbackRef]);
};
//#endregion
exports.useTimeout = useTimeout;
//# sourceMappingURL=index.cjs.map