October 2019
Intermediate to advanced
426 pages
11h 49m
English
The useTimeout Hook can be used just like setTimeout. We are now going to implement a component that triggers after 10 seconds have passed:
import React, { useState } from 'react'import { useTimeout } from 'react-hookedup'
export default function UseTimeout () { const [ ready, setReady ] = useState(false)
useTimeout(() => setReady(true), 10000)
return <div>{ready ? 'ready' : 'waiting...'}</div>}
Alternatively, we could use an Effect Hook in combination with setTimeout ...
Read now
Unlock full access