React sensor hook that tracks if user on the page is idle.
import {useIdle} from 'react-use';
const Demo = () => {
const isIdle = useIdle(3e3);
return (
<div>
<div>User is idle: {isIdle ? 'Yes π΄' : 'Nope'}</div>
</div>
);
};
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.