intermediate · 23 minute study
Choose one owner for each fact
Duplicated state makes forms, filters, selected rows and totals disagree with one another.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- Compose small contracts into useful interfaces — Composition prevents giant condition-heavy components and makes accessible behavior reusable.
First, build a mental model
State is a source of truth. If two components need to coordinate one fact, move that fact to their nearest useful shared owner and pass values and events down.
- Store the minimal changing facts.
- Derive values that can be calculated from current props/state.
- Lift shared state to a common owner rather than synchronizing duplicate copies.
- Context distributes access; it does not determine the right owner or replace authorization.
function Inventory({ items }) {
const [query, setQuery] = useState('');
const [selectedId, setSelectedId] = useState(null);
const visible = items.filter(item => item.name.includes(query));
const selected = items.find(item => item.id === selectedId) ?? null;
return <InventoryView query={query} onQuery={setQuery}
items={visible} selected={selected} onSelect={setSelectedId} />;
}- Stored
query and selectedId are the independent changing facts.
- Derived
visible and selected are recalculated from the current source data.
- Shared view
The child receives one coherent set of values and callbacks.
Production thinking
Take this beyond the example.
Use context for broadly needed access and reducers for complex transitions. Keep authoritative business decisions on the trusted side of the application boundary.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · A form is state, semantics and feedback →