Stateful vs Stateless Composables
Separate logic from presentation.
Two Kinds of Composables
Every Composable is either stateful (it holds its own data) or stateless (it just renders what you pass in). Knowing which is which shapes your whole app.
What Stateful Means
A stateful Composable remembers something across recompositions, usually with remember. It owns and changes its own data.
fun Counter() {
var count by remember { mutableStateOf(0) }
Button(onClick = { count++ }) { Text("Count: " + count) }
}All lessons in this course
- Stateful vs Stateless Composables
- Hoist State with value & onValueChange
- Single Source of Truth
- Compose State Slots & Content Lambdas