useTimeout
Custom hook that handles timeouts in React components using the [`setTimeout API`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout).
Custom hook that handles timeouts in React components using the setTimeout API.
Usage
import { useTimeout } from "@tilt-legal/cubitt-components/utilities/hooks";
// Usage of useTimeout hook
useTimeout(() => {
// Code to be executed after the specified delay
}, 1000); // Set a timeout of 1000 milliseconds (1 second)API
Signature
declare function useTimeout(callback: () => void, delay: number | null): void;Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
callback | () => void | The function to be executed when the timeout elapses. | - |
delay | `number | null` | The duration (in milliseconds) for the timeout. Set to null to clear the timeout. |
Return Value
| Value | Type | Description |
|---|---|---|
return | void | This hook does not return anything. |