salomonbrys
09/27/2021, 6:01 PMOleksandr Karpovich [JB]
09/27/2021, 6:23 PMsalomonbrys
09/27/2021, 8:23 PMsalomonbrys
09/27/2021, 9:28 PMobject MyStyle : StyleSheet()
fun main() {
renderComposableInBody {
println("Composing!")
Style(MyStyle)
var bool by remember { mutableStateOf(false) }
Div({
classes(MyStyle.css {
backgroundColor(if (bool) Color.red else Color.blue)
})
}) {
Button({
onClick { bool = !bool }
}) { Text("Change color!") }
}
}
}
While the following code only composes once:
fun main() {
renderComposableInBody {
println("Composing!")
var bool by remember { mutableStateOf(false) }
Div({
style {
backgroundColor(if (bool) Color.red else Color.blue)
}
}) {
Button({
onClick { bool = !bool }
}) { Text("Change color!") }
}
}
}
salomonbrys
09/28/2021, 9:29 AM