Function yew_hooks::use_timeout [−][src]
Expand description
A hook that schedules a timeout to invoke callback in millis milliseconds from now.
The timeout will be cancelled if millis is set to 0.
Example
#[function_component(Timeout)]
fn timeout() -> Html {
let state = use_state(|| 0);
{
let state = state.clone();
use_timeout(move || {
state.set(1);
}, 2000);
}
html! {
<>
{ *state }
</>
}
}