DEV Community

Filip
Filip

Posted on • Edited on

react-activity-detector - Check if the user is idle

I haven't been active in the OS community, or here, but that might change!
Most of my career I was focused on the backend (C# and partially Java), but I felt that I need push myself to something new.
New projects came, and required me to push myself from my comfort zone, and required me to learn ReactJS, and before that JavaScript.
I must say, it's a lot of fun working with ReactJS (in good and bad way).
It's pretty easy to pickup (mostly saying this since I have spend a lot of time working with strong typing languages like C# and Java).

Now, to the package!

You can check the package on react-activity-detector

What's its purpose?
If you have an app, and need to detect if the user is idle after N seconds/minutes/hours + cross tab functionality!

How to implement it

import ActivityDetector from 'react-activity-detector';

const customActivityEvents = [
    'click',
    'keydown',
];

const signOut = () => {
console.log("The user is loged out");
}

<ActivityDetector activityEvents={customActivityEvents} isActive={true} timeout={5*1000} signOut={signOut}/>

Enter fullscreen mode Exit fullscreen mode

You can find more on the link, and to check out the code you can visit github.com.

Just a note, it's still in early stage and I would be grateful for any suggestions or feedbacks!

Top comments (0)