Jetpack Compose

5 concepts · 10 practice questions

Recomposition

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

Also covered

remember and rememberSaveable
State hoisting
Side effects
Stability and skipping

Sign in to read the rest and take the 10-question test.

Sign in to continue