I have a simple composable function, but it is not behaving as I would expect:
@Composable
fun Example() {
val show = remember {
mutableStateOf(true)
}
if (show.value) {
Text("Showing")
}
LaunchedEffect(Unit) {
delay(3000)
show.value = false
}
}
Expectation: Text is not shown after 3 seconds
Observation: Sometimes text is not shown after 3 seconds, but sometimes it continues to be shown
Can someone please explain why the if statement sometimes seems not to evaluate. It is seemingly random as well which is even more confusing.
3