mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
526 B
526 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>Use is idle: {isIdle ? 'Yes' : 'No'}</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.