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