mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
534 B
534 B
useIdle
React sensor hook that tracks if user on the page is idle.
Usage
import {useIdle} from 'react-use';
const Demo = () => {
const isIdle = useIdle(3e3);
return (
<div>
<div>User is idle: {isIdle ? 'Yes 😴' : 'Nope'}</div>
</div>
);
};
Reference
useIdle(ms, initialState);
ms— time in milliseconds after which to consider use idle, defaults to60e3— one minute.initialState— whether to consider user initially idle, defaults to false.