Hi all :slightly_smiling_face: Been reading about ...
# compose
l
Hi all 🙂 Been reading about CompositionLocal and I’m trying to understand when you would use a static CompositionLocal over a dynamic one. Is there any guidance on this anywhere? From my understanding a static CompositionLocal will cause the entire tree below to recompose, which seems worse than always just recomposing the Composable(s) using it
z
a static CompositionLocal will cause the entire tree below to recompose, which seems worse than always just recomposing the Composable(s) using it
Exactly, so static locals are intended for when the value will never change, or only change very rarely. E.g. the
Context
is provided via a static local, because the
Context
is strongly associated to the entire composition (it’s used to create the android views that host it) and it can never change for a given composition.
👆 1
👍 2