user2297550
user2297550

Reputation: 3356

Wrong Button Clicking in Jetpack Compose Web

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") }
    }
}

Upvotes: 0

Views: 47

Answers (0)

Related Questions