useIdle
useIdle
is a custom hook that detects whether the user has been idle for a certain amount of time in milliseconds.
Current state: idle
const idle = useIdle(2000)
return <Text>Current state: {idle ? "idle" : "not idle"}</Text>
If you use this code, you need to add
"use client"
to the top of the file.Usage
import { useIdle } from "@yamada-ui/react"
import { useIdle } from "@/components/ui"
import { useIdle } from "@workspaces/ui"
const idle = useIdle(2000)