Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 723 Bytes

useIdle.md

File metadata and controls

34 lines (23 loc) · 723 Bytes

useIdle

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.

Usage

import { useIdle } from 'use-haki';

const App = () => {
  const isIdle = useIdle({ timeToIdle: 1000 });

  return (
    <section>
      <h1>{isIdle ? 'Are you still there? 👀' : 'Hi there 👋'}</h1>
    </section>
  );
};

Reference

const isIdle = useIdle(options);
  • isIdle - gives boolean, idle state
  • options - provide some extra options for idle state

Returns

  • isIdle