Is the SideEffect `deriveStateOf` not able to work...
# compose
e
Is the SideEffect
deriveStateOf
not able to work together with
snapshotFlow
in aiding recomposition? Separate them out seems working, but not together. The code example in https://stackoverflow.com/q/70771821/3286489
z
Hm, that’s really weird. Will try to repro in a bit
e
Thanks. The more I try, the more I feel it’s a bug. But I cannot confirm so.
a
I can reproduce, and it is super weird… Here’s a more minimized version:
Copy code
var count by remember { mutableStateOf(0) }
    var fromSnapshot by remember { mutableStateOf(false) }
    val fromDerived by remember { derivedStateOf { count > 0 } }

    LaunchedEffect(Unit) {
        snapshotFlow { count }.collect { fromSnapshot = it > 1 }
    }

    Column {
        Text("Button clicked at least 1 time: $fromDerived")
        Text("Button clicked at least 2 times: $fromSnapshot")
        Button(onClick = { count++ }) {
            Text("Increase count")
        }
    }
fromSnapshot
will be set to
true
when the button is clicked twice, but the text won’t be updated to reflect that.
a
What version of Compose are you using? If you are using 1.0, can you try 1.1 RC?
e
A bug report is file at https://issuetracker.google.com/issues/215402574. I’m using 1.0.5
👍 1
Thanks for all the inputs. I will try 1.1 and see too.
👀 1