0PricingLogin
Jetpack Compose Academy · Lesson

remember & mutableStateOf

Store state that survives recomposition.

What Is State?

In Compose, state is any value that can change over time and that your UI cares about, like a counter or a typed name. 🙂

Plain Variables Don't Work

A normal var inside a Composable changes its value, but Compose never notices, so the screen stays exactly the same.

var count = 0
Button(onClick = { count++ }) {
    Text("Count: " + count)
}

All lessons in this course

  1. remember & mutableStateOf
  2. Recomposition: What Triggers a Redraw
  3. Build a Tap Counter
  4. rememberSaveable Across Rotation
← Back to Jetpack Compose Academy