Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 1.42 KB

README.md

File metadata and controls

65 lines (45 loc) · 1.42 KB

use-active-detect

hook for detecting when a user is active.

NPM JavaScript Style Guide

Install

npm install --save use-active-detect

Usage

useActiveDetect

function useActiveDetect(options: Options): void;
Example
import * as React from 'react';

import { useActiveDetect } from 'use-active-detect';

const Example = () => {
  useActiveDetect({
    onActive: () => {
      console.log('active');
    },
  });

  return <div>...</div>;
};

Options

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.
Example
useActiveDetect({
  onActive: (event) => {
    console.log(event);
  },
  wait: 1000,
  element: document.body,
});

License

MIT © https://github.com/yyz945947732/use-active-detect


This hook is created using create-react-hook.