Function use_atom_value

Source
pub fn use_atom_value<'hook, T>() -> impl 'hook + Hook<Output = Rc<T>>
where T: Atom + 'static + 'hook,
Expand description

A read-only hook to connect to the value of an Atom.

Returns Rc<T>.

§Example

#[function_component(Reader)]
fn reader() -> Html {
    let username = use_atom_value::<Username>();

    html! { <div>{"Hello, "}{username}</div> }
}

§Note

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

pub fn use_atom_value<T>() -> Rc<T>
where
    T: Atom + 'static,
{
    /* implementation omitted */
}