useTimeout ​
Hook that executes a callback function after a specified delay
time
medium
test coverage
Last changed: 3 months ago
Installation ​
Library
CLI
Manual
typescript
import { useTimeout } from '@siberiacancode/reactuse';Usage ​
typescript
const { clear, ready } = useTimeout(() => {}, 5000);Demo ​
Api ​
Parameters
| Name | Type | Default | Note |
|---|---|---|---|
| callback | () => void | - | The function to be executed after the timeout |
| delay | number | - | 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 • DemoContributors ​
D
H
T