Neurologically Paralyzing Mouseovers
    Wondering what’s next for npm?Check out our public roadmap! »

    react-use-activity

    0.1.0 • Public • Published

    react-use-activity

    build version downloads license

    React hook that let's you react to user activity or inactivity

    Installation

    Use one of the two based on your project's dependency manager.

    $ npm install react-use-activity --save
    
    $ yarn add react-use-activity

    Getting started

    import useActivity from 'react-use-activity';
    
    useActivity({
      timeout: 2000,
      onActivity: () => {},
      onInactivity: () => {},
      activityEvents: 'mousemove',
    });

    Arguments:

    • options
      • timeout - the duration (ms) of inactivity that should trigger onInactivity - defaults to 2000
      • onActivity - a callback that is executed any time user activity is registered
      • onInactivity - a callback that is executed when user is inactive for the specified timeout
      • activityEvents - a space delimited string specifying dom events that should be treated as user activity - defaults to mousemove

    Running example

    Use one of the following based on your dependency manager.

    $ npm run start:example
    
    $ yarn start:example

    Licence

    MIT © Mutai Mwiti | GitHub | GitLab

    DISCLAIMER: All opinions expressed in this repository are mine and do not reflect any company or organisation I'm involved with.

    Install

    npm i react-use-activity

    DownloadsWeekly Downloads

    5

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    5.87 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar