```var state1 by remember { mutableStateOf(1) } va...
# compose
v
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
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
oh thank you derivedstateof may come handy