val s = state { 1 }
Text(s.value.toString())
remember {
s.value = s.value + 1
}
it seems on dev08, updating a mutable state in the same frame will not triger recomposition? Is this a bug? (expected text should be "2")
a
Andrey Kulikov
04/03/2020, 9:58 AM
hey! It is an expected behaviour right now. the state was created in the same frame so all the modifications on this state within the same frame are considered as the initial object constructions and not causing recomposition. @Chuck Jazdzewski [G] can provide more details, I remember we were discussion detection of the cases like this when we first read the value in the composition and then updated it in the same frame to handle it more smarter. but actually what exactly do you try to achieve with it? maybe this pattern is not a proper one for your usecase
yes, this was changed intentionally for other reasons. we actually talked about this particular difference in behavior at length! But i didn’t think there would actually be any code in the wild that would be affected by it :)