https://kotlinlang.org logo
#compose
Title
# compose
v

Vivek Sharma

03/05/2021, 8:51 PM
Copy code
var state1 by remember { mutableStateOf(1) }
var state2 by remember { mutableStateOf(100 - state1) }
I am having kind of this code, I am updating
state1
and
state2 should update when state1 update
, but
state2 is not getting updated
, am I doing something wrong?
d

Denis

03/05/2021, 9:16 PM
shouldn't it be
remember(state1)
? and there's https://developer.android.com/jetpack/compose/lifecycle#derivedstateof, maybe it's better for your use case?
2
v

Vivek Sharma

03/06/2021, 6:25 PM
oh thank you derivedstateof may come handy
7 Views