Function yew_hooks::use_effect_once[][src]

pub fn use_effect_once<Callback, Destructor>(callback: Callback) where
    Callback: FnOnce() -> Destructor + 'static,
    Destructor: FnOnce() + 'static, 
Expand description

A lifecycle hook that runs an effect only once.

Example

#[function_component(EffectOnce)]
fn effect_once() -> Html {
    use_effect_once(|| {
        debug!("Running effect once on mount");
         
        || debug!("Running clean-up of effect on unmount")
    });
     
    html! {
        <>
        </>
    }

}