Skip to content

alita-moore/react-native-use-idle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple way to detect inactivity.

// you need to add IdleProvider at the top level
const isIdle = useIdle()

Getting Started

Install

yarn add react-native-use-idle

Add the Provider At the Top Level

import { IdleProvider } from "react-native-use-idle";

// top level of code you want to monitor
const App = () => {
    return (
        // optionally set a timeForInactivity variable (default 30s)
        <IdleProvider>
            {...your app}
         </IdleProvider>
    )
}

Using useIdle

import { useIdle } from "react-native-use-idle";

const Component = () => {
    const isIdle = useIdle();
    useEffect(() => {
         if (!isIdle) console.log("not idle");
         console.log("is idle");
    },[])
}

About

useIdle returns true or false if a user is idle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published