Loading...
Please waitLoading...
Please waitpnpm dlx uselab@latest add use-timeout
import * as React from "react"
import { useTimeout } from "@/hooks/use-timeout"
export function Component() {
const [hasTimeElapsed, setHasTimeElapsed] = React.useState(false)
useTimeout(() => {
setHasTimeElapsed(true)
}, 5000)
return (
<p>{hasTimeElapsed ? "5 seconds has passed!" : "The timer is running…"}</p>
)
}| Name | Type | Description | Default Value | Optional |
|---|---|---|---|---|
callback | () => void | The function to be executed when the timeout elapses. | - | No |
delay | null | number | The duration (in milliseconds) for the timeout. Set to null to clear the timeout. | - | No |
You have 1s to defuse (click) the bomb or it will explode