/use-active-detect

hook for detecting when a user is active.

Primary LanguageTypeScriptMIT LicenseMIT

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.