The app that remembers
Tap a heart and it fills red and stays that way — the app remembered your tap. 'State' is the app's memory, and events (your taps and swipes) are what change it, making a static screen come alive.
State is what changes
State is the data an app remembers — the current tab, a counter, a form's text. When a user event fires (a tap, a keystroke), a handler updates the state, and the UI re-renders to reflect the new value. This loop — event → update state → re-render — is the heartbeat of an interactive app.
onTap: count = count + 1 → the label re-renders showing the new count
Lab · Trace the loop
- A counter starts at 0. The user taps '+'.
- Which handler runs, and what does it change?
- What does the screen show next, and why?
What you should see: The tap fires the increment handler, state goes 0 → 1, and the UI re-renders to show 1 — event, state update, re-render.