Skip to main content

rememberKeyed

Function rememberKeyed 

Source
pub fn rememberKeyed<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. rememberKeyed stores the key beside the value and re-runs init on mismatch — the JC remember(key1) { ... } contract.