5 concepts · 10 practice questions
Compose re-runs a composable when state it read changes. Recomposition is scoped to the smallest restartable function that read the state, it can run in any order and can be skipped, so a composable must be side-effect free and cheap to call.
@Composable
fun Counter() {
var count by remember { mutableStateOf(0) }
Button(onClick = { count++ }) {
Text("Clicked $count") // only this scope re-runs
}
}
Sign in to read the rest and take the 10-question test.
Sign in to continue