So, I have some code that basically boils down to this:
class State {
var item by mutableStateOf<IClass?>(null)
}
@Composable
fun SomeUi(state: State) {
Text("Item is ${state.item}")
}
SomeUi()
is rendered to screen, and
state.item
is changed from
null
to some value a little afterwards. But
SomeUi
never picks up on that update and thus the text keeps saying
"Item is null"
. But the way I understand the Compose state system, this should work fine, shouldn't it?
I can verify that
state.item
does change its value (by just periodically printing it in a coroutine). What's odd is that if I experimentally change
IClass?
to
String?
it works again.
I want to put more effort into debugging it, but first I'd like to verify that I'm not simply misunderstanding something about State and how it's supposed to work.