Function use_effect_update

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

This hook ignores the first invocation (e.g. on mount). The signature is exactly the same as the use_effect hook.

§Example

use yew_hooks::prelude::*;

#[function_component(UseEffectUpdate)]
fn effect_update() -> Html {
    use_effect_update(|| {
        debug!("Running effect only on updates");

        || ()
    });
    
    html! {
        <>
        </>
    }
}

§Note

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

pub fn use_effect_update<Callback, Destructor>(callback: Callback)
where
    Callback: FnOnce() -> Destructor + 'static,
    Destructor: FnOnce() + 'static,
{
    /* implementation omitted */
}