Skip to content

Latest commit

Β 

History

History
30 lines (20 loc) Β· 534 Bytes

useIdle.md

File metadata and controls

30 lines (20 loc) Β· 534 Bytes

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>User is idle: {isIdle ? 'Yes 😴' : 'Nope'}</div>
    </div>
  );
};

Reference

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.