remember & mutableStateOf

Composables have no memory

A @Composable function is just that β€” a function. Compose calls it to draw the screen, and calls it again ('recomposes' it) whenever something it reads changes. Here's the catch: every time it's called, any plain var count = 0 inside it resets right back to 0. A composable function has no memory of its own between calls.

That's the job of remember: it tells Compose store this value for me, outside the function, and hand it back unchanged the next time you call me. Pair it with mutableStateOf(...), which creates a value Compose can watch for changes, and you get a variable that both survives recomposition AND triggers a new one when it changes.

New term: recomposition β€” Compose calling a @Composable function again to recompute what's on screen. SwiftUI calls the same idea a re-render.