This hook helps you detecting when the user becomes idle (does not interact with the page for some time) or active in your page.
Hook use activity-detector library.
import { useIdle } from 'use-haki';
const App = () => {
const isIdle = useIdle({ timeToIdle: 1000 });
return (
<section>
<h1>{isIdle ? 'Are you still there? 👀' : 'Hi there 👋'}</h1>
</section>
);
};
const isIdle = useIdle(options);
- isIdle - gives boolean, idle state
- options - provide some extra options for idle state
- isIdle