Is simply changing a local state variable in a com...
# compose
m
Is simply changing a local state variable in a composable considered a side effect?
p
Yes
To answer wether this is bad depends on the context. For example in some cases it might be fine to let things hold their own state. For example the ripple animation
1
m
But it's not mentioned under side effects docs
p
You are right. I think the compose docs on side effects are mostly talking on the effect api
👍 1
But maybe I’m completely wrong and having a switch hold it’s own state is not a side effect at all but rather non state hoisting.
h
Copy code
@Composable 
fun dummy() {
  var foo = 1
  TextField("Hello")
  foo = 2
  if (foo == 2) {
    TextField("2")
}
You should not expect seeing both TextField, and should use
mutableState
, which tells Compose to recompose (update) the execution. AFAIK ripple animation is a class containing mutableStates via a delegate, so updating these
local
variables are fine
1