https://github.com/sakalx/useidle
React hook to handle browser idle
https://github.com/sakalx/useidle
Last synced: 2 months ago
JSON representation
React hook to handle browser idle
- Host: GitHub
- URL: https://github.com/sakalx/useidle
- Owner: sakalx
- License: mit
- Created: 2020-08-19T19:10:55.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-01T19:43:43.000Z (over 4 years ago)
- Last Synced: 2024-03-25T00:00:23.543Z (about 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React hook to track user idle.
Simple, light hook to execute callback during a browser's idle periods.
________________________________________________________
________________________________________________________
#### options
| Name | Type | Description |
| --- | --- | --- |
| **callback** | `function` | A reference to a function that should be called in the near future. |
| **idleTimeout** | `number` | Time in milliseconds to call during the next idle period. Default: 5min (300000ms) |
| **trackEvents** | `array` | List of tracking events. Default: [`click`, `keydown`, `mousedown`, `mousemove`, `touchstart`, `scroll`]|
________________________________________________________
________________________________________________________
### Example
after component mounted will be start tracking Idle,```javascript
import React from 'react';
import useIdle from 'react-use-idle';const App = () => {
const idleCallback = () => {
console.log('idle detected');
};useIdle({
callback: idleCallback,
idleTimeout: 5000, // 5sec
});
return (
...Your App
)
}
```
________________________________________________________
________________________________________________________