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

ParameterTypeDescriptionDefault
callback() => voidThe function to be executed when the timeout elapses.-
delay`numbernull`The duration (in milliseconds) for the timeout. Set to null to clear the timeout.

Return Value

ValueTypeDescription
returnvoidThis hook does not return anything.

On this page