Wrong Button Clicking in Jetpack Compose Web

48 Views Asked by At

Clicking the foo button the second and subsequent times causes the code for the bar button to be executed. It seems related to the collection that I map to P elements.

fun main() {
    renderComposableInBody {
        val words = remember { mutableStateListOf<String>() }
        words.map { P { Text(it) }}
        Button(attrs = { onClick { words.add("foo") } }) { Text("foo") }
        Button(attrs = { onClick { words.add("bar") } }) { Text("bar") }
    }
}
0

There are 0 best solutions below