<State>
{([]) => {
const {safeSetTimeout, safeClearTimeout} = useSafeTimeout()
let timeoutId = null
const handleOnClick = () => {
timeoutId = safeSetTimeout(() => window.alert('hello!'), 5000)
}
const cancelTimeout = () => {
safeClearTimeout(timeoutId)
}
return (
<>
<Button onClick={handleOnClick}>Click me</Button>
<Button onClick={cancelTimeout}>Cancel timeout</Button>
</>
)
}}
</State>