Skip to main content

useDelay()

function useDelay(): {
cancel: () => void;
isPending: () => boolean;
schedule: (callback, milliseconds) => void;
};

Manage one delayed callback. Scheduling again replaces the pending callback, and unmounting cancels it. Returned methods are stable across renders.

Returns

{
cancel: () => void;
isPending: () => boolean;
schedule: (callback, milliseconds) => void;
}
NameType
cancel()() => void
isPending()() => boolean
schedule()(callback, milliseconds) => void