useIdle ​
Hook that defines the logic when the user is idle
sensors
test coverage
Last changed: last month
Installation ​
Library
CLI
Manual
typescript
import { useIdle } from '@siberiacancode/reactuse';
Usage ​
typescript
const { idle, lastActive } = useIdle();
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
milliseconds? | number | ONE_MINUTE | The idle time in milliseconds |
options.initialState? | boolean | false | The options for the hook |
options.events? | Array<keyof WindowEventMap> | IDLE_EVENTS |
Returns
UseIdleReturn
Type declaration ​
typescript
export interface UseIdleOptions {
/** The idle events */
events?: Array<keyof DocumentEventMap>;
/** The idle state */
initialValue?: boolean;
}
export interface UseIdleReturn {
/** The idle state */
idle: boolean;
/** The last active time */
lastActive: number;
}
Source ​
Source • DemoContributors ​
D
H