mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
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
31 lines
534 B
Markdown
31 lines
534 B
Markdown
# `useIdle`
|
|
|
|
React sensor hook that tracks if user on the page is idle.
|
|
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
import {useIdle} from 'react-use';
|
|
|
|
const Demo = () => {
|
|
const isIdle = useIdle(3e3);
|
|
|
|
return (
|
|
<div>
|
|
<div>User is idle: {isIdle ? 'Yes 😴' : 'Nope'}</div>
|
|
</div>
|
|
);
|
|
};
|
|
```
|
|
|
|
|
|
## Reference
|
|
|
|
```js
|
|
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.
|