Function leptos::as_child_of_current_owner
source · pub fn as_child_of_current_owner<T, U>(f: impl Fn(T) -> U) -> impl Fn(T)where
T: 'static,
Expand description
Wraps the given function so that, whenever it is called, it creates a child node owned by whichever reactive node was the owner when it was created, runs the function, and returns a disposer that can be used to dispose of the child later.
This can be used to hoist children created inside an effect up to the level of a higher parent, to prevent each one from being disposed every time the effect within which they’re created is run.
For example, each row in a <For/>
component could be created using this,
so that they are owned by the <For/>
component itself, not an effect
running within it.
§Panics
Panics if there is no current reactive runtime.