Example:
I have a @Composable func WorkoutScreen(...)
which injects a dedicated ViewModel (e.g. with hilt). It displays some different child composables like @Composable func ProgressView(...)
and some others. ProgressView
is the only composable in the whole screen, which observes/needs a specific State
property x from the injected ViewModel. Would it be bad practice to pass the ViewModel from WorkoutScreen as parameter down to ProgressView? Or should I just pass the States value only?
Let's think this further and say I pass only the State. Also let's say, not ProgressView is the one needing the State, but just another child of ProgressView. If the State changes now, the whole ProgressView might be recompositioned since "its input changes" (instead of just the child), if I understood correctly. Wouldn't this lead to unnecessary recomps?