pub fn use_effect_once<'hook, Callback, Destructor>(
callback: Callback,
) -> impl 'hook + Hook<Output = ()>
Expand description
A lifecycle hook that runs an effect only once.
§Example
use yew_hooks::prelude::*;
#[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! {
<>
</>
}
}
§Note
When used in function components and hooks, this hook is equivalent to:
pub fn use_effect_once<Callback, Destructor>(callback: Callback)
where
Callback: FnOnce() -> Destructor + 'static,
Destructor: FnOnce() + 'static,
{
/* implementation omitted */
}