useIdleReact 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 to 60e3 β one minute.initialState β whether to consider user initially idle, defaults to false.// TODO: implement useIdle function notImplemented(..._args: any[]): any { throw new Error('Not implemented'); } export default notImplemented; export const useIdle = notImplemented;
Tests