Function bounce::use_slice_value
source · pub fn use_slice_value<'hook, T>() -> impl 'hook + Hook<Output = Rc<T>>where
T: Slice + 'static + 'hook,
Expand description
A read-only hook to connect to the value of a Slice
.
Returns Rc<T>
.
Example
#[function_component(CounterComp)]
fn counter_comp() -> Html {
let ctr = use_slice_value::<Counter>();
html! {
<div>
<div>{"Current Counter: "}{ctr.0}</div>
</div>
}
}
Note
When used in function components and hooks, this hook is equivalent to:
pub fn use_slice_value<T>() -> Rc<T>
where
T: Slice + 'static,
{
/* implementation omitted */
}