Home

Awesome

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

optiondefaultDescription
onActive() => {}Function to call when user becomes active.
wait1000 * 30The number of milliseconds to delay.
elementdocumentElement 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.