Function use_is_mounted

Source
pub fn use_is_mounted<'hook>() -> impl 'hook + Hook<Output = Rc<dyn Fn() -> bool>>
Expand description

A hook returns true if component is mounted and false otherwise.

§Example

use yew_hooks::prelude::*;

#[function_component(IsMounted)]
fn is_mounted() -> Html {
    let is_mounted = use_is_mounted();
    
    html! {
        <>
            { is_mounted() }
        </>
    }
}

§Note

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

pub fn use_is_mounted() -> Rc<dyn Fn() -> bool> {
    /* implementation omitted */
}