Function dioxus_hooks::use_memo

source ·
pub fn use_memo<T, D>(
    cx: &ScopeState,
    dependencies: D,
    callback: impl FnOnce(D::Out) -> T
) -> &Twhere
    T: 'static,
    D: UseFutureDep,
Expand description

A hook that provides a callback that executes after the hooks have been applied

Whenever the hooks dependencies change, the callback will be re-evaluated.

  • dependencies: a tuple of references to values that are PartialEq + Clone

Examples


#[inline_props]
fn app(cx: Scope, name: &str) -> Element {
    use_memo(cx, (name,), |(name,)| {
        expensive_computation(name);
    }))
}