Function freya::prelude::use_effect

pub fn use_effect<T, F, D>(
    cx: &ScopeState,
    dependencies: D,
    future: impl FnOnce(<D as UseFutureDep>::Out) -> F
)where
    T: 'static,
    F: Future<Output = T> + 'static,
    D: UseFutureDep,
Expand description

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

Whenever the hooks dependencies change, the future will be re-evaluated. If a future is pending when the dependencies change, the previous future will be allowed to continue

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

Examples


#[inline_props]
fn app(cx: Scope, name: &str) -> Element {
    use_effect(cx, (name,), |(name,)| async move {
        set_title(name);
    }))
}