react-use/docs/useIdle.md
streamich 61700675cd chore: 🤖 don't install only large dependencies
This change removes useCallbag hook, it also reverts back changes for
hooks that only have tiny dependencies or dependencies that could have
been part of the hook itself. Effectivly only KeyboardJS and Rebound are
large packages that only partially are used by react-use, hence require
user to install them separately.

BREAKING CHANGE: 🧨 useCallbag hook is removed, some hooks KeyboardJS and Rebound installed
separately
2019-03-25 13:19:37 +01:00

534 B

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.