react-native-use-idle
v1.14.0
Published
useIdle returns a boolean if idle
Downloads
19
Readme
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");
},[])
}