use-active-detect
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i use-active-detect

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

90.1 kB

Total Files

13

Last publish

Collaborators

  • yaoyuanzhang