pub fn use_update<'hook>() -> impl 'hook + Hook<Output = Rc<dyn Fn()>>Expand description
A hook returns a function that forces component to re-render when called.
§Example
use yew_hooks::prelude::*;
#[function_component(Update)]
fn update() -> Html {
let update = use_update();
let onclick = Callback::from(move |_| {
update();
});
html! {
<>
<button {onclick}>{ "Update" }</button>
</>
}
}§Note
When used in function components and hooks, this hook is equivalent to:
/// A hook returns a function that forces component to re-render when called.
///
/// # Example
///
/// ```rust
/// # use yew::prelude::*;
/// #
/// use yew_hooks::prelude::*;
///
/// #[function_component(Update)]
/// fn update() -> Html {
/// let update = use_update();
///
/// let onclick = Callback::from(move |_| {
/// update();
/// });
///
/// html! {
/// <>
/// <button {onclick}>{ "Update" }</button>
/// </>
/// }
/// }
/// ```
pub fn use_update() -> Rc<dyn Fn()> {
/* implementation omitted */
}