hook for detecting when a user is active.
npm install --save use-active-detect
function useActiveDetect(options: Options): void;
import * as React from 'react';
import { useActiveDetect } from 'use-active-detect';
const Example = () => {
useActiveDetect({
onActive: () => {
console.log('active');
},
});
return <div>...</div>;
};
option | default | Description |
---|---|---|
onActive | () => {} | Function to call when user becomes active. |
wait | 1000 * 30 | The number of milliseconds to delay. |
element | document | Element to bind activity listeners to. |
useActiveDetect({
onActive: (event) => {
console.log(event);
},
wait: 1000,
element: document.body,
});
MIT © https://github.com/yyz945947732/use-active-detect
This hook is created using create-react-hook.