State management
Keeping track of data and UI state so the interface stays consistent.
State management decides where data lives, how it changes and how the UI stays in sync with the server. Many bugs come from state stored in two places. Simple, explicit state makes features easier to change.
Why it matters for a product engineer
State management decides where data lives, how it changes and how the interface stays in step with the server. Many bugs come from the same data stored in two places that disagree. Simple, explicit state makes features easier to change, and it decides what users see when the network is slow or gone.
How to do it
- List each piece of state and choose one owner for it: the URL, the component, the browser’s storage or the server.
- Keep state as close as possible to where it is used. Most state does not need to be global.
- Treat server data as a cache with rules: when to fetch it again, and what to show while it loads.
- Put state people share or bookmark, such as filters and tabs, in the URL.
- When the same data lives in two places, write the merge rule down before you write code.
- Test the hard cases: two tabs, offline, a slow request and a second device.
Common mistakes
- Copying server data into global state and forgetting to update it.
- One global store for everything, so any change can break anything.
- No rule for conflicts, so the last request to arrive wins by accident.
- Loading spinners for data the page already had.
Example
On this site, progress on the skills map works without an account. The page reads the browser’s copy. When someone signs in, each change also goes into a queue in the browser, which keeps it until the server confirms it, so changes made offline go out later. The server keeps the newest change for each skill, so an old laptop cannot overwrite newer work.
Where progress lives on this site, and the rule for each place
| Where it lives | The rule | |
|---|---|---|
| What the page shows | The browser's copy | Works offline and without an account |
| Changes not yet saved | A queue in the browser | Kept until the server confirms them |
| Progress across devices | The account on the server | The newest change for each skill wins |
| Visitors without an account | Only the browser | The page never calls the server |
Each place has one job and one written rule. The merge rule is per skill, so two devices rarely conflict at all.
Observedproductengineer.pro, the progress sync code and the API notes, Nov 2026
Sources: Application state management with React (Kent C. Dodds) ↗
Resources
1- articleStart here
Application state management with React ↗
Kent C. Dodds · 15 minKeep state close to where it is used and server data in a cache; most apps need far less global state than they have.