Skip to main content

remember_keyed

Function remember_keyed 

Source
pub fn remember_keyed<K, T>(key: K, init: impl FnOnce(&K) -> T) -> T
where K: PartialEq + 'static, T: Clone + 'static,
Expand description

Like remember, but recomputes whenever key changes.

A plain remember is keyed only by composition position: when a slot is reused with different inputs (a list row that changes identity, an icon whose path prop changes), the stale value survives. remember_keyed stores the key beside the value and re-runs init on mismatch — the JC remember(key1) { ... } contract.