I almost skipped past this. It looked like a small refactor. It ended up being the first time React's "one source of truth" idea actually clicked for me instead of just being a phrase I nodded along to.
Here's the project: a grid of colored pads that toggle on/off when clicked. Simple UI, simple idea.
Where I started: derived state
My first instinct was to create state based on data that lived somewhere else in the component tree — what's usually called derived state. It technically worked. Buttons rendered, colors showed up. But something about it felt fragile, and I couldn't articulate why yet.
Where I ended up: one source of truth






