Just a simple question. Is it a compose anti-patte...
# compose
a
Just a simple question. Is it a compose anti-pattern to have a complete
State
as input of your root composable and have all subcomposables take either directly some subelements of that state or some
derivedState
? I can imagine that the runtime will trigger a recalc on the root component every time the top-level state is changed and this might be suboptimal.
s
https://www.jetpackcompose.app/articles/donut-hole-skipping-in-jetpack-compose that's fine yes. Compose is smart enough to skip child components when it knows that it can. Just gotta make sure that the values provided are stable for those optimizations to kick in https://chris.banes.dev/composable-metrics/
a
Thanks!
m
No it not an anti pattern. It is the best way to define the state of your screen