Skip to content

useTimeout ​

Hook that executes a callback function after a specified delay

time
test coverage
Last changed: last month

Installation ​

Library
CLI
Manual
typescript
import { useTimeout } from '@siberiacancode/reactuse';

Usage ​

typescript
const { clear, ready } = useTimeout(() => {}, 5000);

Demo ​

Api ​

Parameters

NameTypeDefaultNote
callback() => void-The function to be executed after the timeout
delaynumber-The delay in milliseconds before the timeout executes the callback function

Returns

UseTimeoutReturn

Type declaration ​

typescript
interface UseTimeoutReturn {
  /**  Timeout is ready state value */
  ready: boolean;
  /** Function to clear timeout */
  clear: () => void;
}

Source ​

Source • Demo

Contributors ​

D
debabin
debabin
H
hywax
hywax
T
triangle
triangle

Released under the MIT License.