pub fn use_raf<'hook>(
millis: u32,
delay: u32,
) -> impl 'hook + Hook<Output = f64>
Expand description
An animation hook that forces component to re-render on each requestAnimationFrame
,
returns percentage of time elapsed. millis
- milliseconds for how long to keep re-rendering component.
delay
— delay in milliseconds after which to start re-rendering component.
§Example
use yew_hooks::prelude::*;
#[function_component(UseRaf)]
fn raf() -> Html {
let elapsed = use_raf(5000, 1000);
html! {
<>
{ elapsed }
</>
}
}
§Note
When used in function components and hooks, this hook is equivalent to:
pub fn use_raf(millis: u32, delay: u32) -> f64 {
/* implementation omitted */
}