I have an object wrapped in `mutableStateOf` and i...
# compose-desktop
c
I have an object wrapped in
mutableStateOf
and inside the object I have string property. Im trying to use that string property for
TextField
but when I type in it, it doesn't change the text value in UI. Whats the proper way of doing this? Thanks In parent class I have
Copy code
var config by mutableStateOf(SomeConfig(""))
and then I call it like this
Copy code
TextField(config.token, onValueChange = {
            config.token = it
        })
r
Either
SomeConfig
needs to be immutable, or it shouldn't be a state while
token
should be.
l
config = config.copy(token = it)
assuming SomeConfig is a data class
a
Remember to also wrap your mutable state in a
remember {}
block
c
@Ruckus That is what I ended up doing (making the properties of
SomeConfig
a mutable state one by one), I was just under the assumption that wrapping the object itself will automatically apply to any changes for its properties