Function use_mount

Source
pub fn use_mount<'hook, Callback>(
    callback: Callback,
) -> impl 'hook + Hook<Output = ()>
where Callback: FnOnce() + 'static + 'hook,
Expand description

A lifecycle hook that calls a function after the component is mounted.

§Example

use yew_hooks::prelude::*;

#[function_component(Mount)]
fn mount() -> Html {
    use_mount(|| {
        debug!("Running effect once on mount");
    });
    
    html! {
        <>
        </>
    }
}

§Note

When used in function components and hooks, this hook is equivalent to:

pub fn use_mount<Callback>(callback: Callback)
where
    Callback: FnOnce() + 'static,
{
    /* implementation omitted */
}
OSZAR »