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
- remember & mutableStateOf
- Recomposition: What Triggers a Redraw
- Build a Tap Counter
- rememberSaveable Across Rotation