@arolariu/components
Version:
🎨 70+ beautiful, accessible React components built on Base UI. TypeScript-first, CSS Modules styling, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡
28 lines • 925 B
TypeScript
/**
* Executes a callback after a specified delay with automatic cleanup.
*
* @remarks
* This hook wraps `setTimeout` and automatically clears the timeout when the component
* unmounts or when the delay changes. Setting `delay` to `null` disables the timeout.
*
* The timeout is reset whenever the `callback` or `delay` changes, ensuring the most
* recent callback is always executed.
*
* @param callback - The function to execute after the delay.
* @param delay - The delay in milliseconds, or `null` to disable the timeout.
*
* @example
* ```tsx
* function DelayedMessage() {
* const [visible, setVisible] = useState(false);
*
* useTimeout(() => {
* setVisible(true);
* }, 3000);
*
* return visible ? <p>Message appeared!</p> : <p>Waiting...</p>;
* }
* ```
*/
export declare function useTimeout(callback: () => void, delay: number | null): void;
//# sourceMappingURL=useTimeout.d.ts.map