Home > Net >  StateFlow.value should not be called within composition
StateFlow.value should not be called within composition

Time:10-20

I downloaded Android Studio Bumblebee beta today and noticed a new warning:

"StateFlow.value should not be called within composition"

Why shouldn't we call StateFlow.value within composition?

CodePudding user response:

Because in composition you should be listening to events, not just reading the current one. If you read only the current one then your view won't get recomposed after the value is changed.

I mean - maybe there is a valid use case for that, but i never encountered one. I guess the warning you saw is just to warn users that they are trying to do something they probably don't want to

  • Related