beginner · 20 minute study
Compose small contracts into useful interfaces
Composition prevents giant condition-heavy components and makes accessible behavior reusable.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- UI is a description produced from a state snapshot — Understanding rendering makes state updates predictable before you memorize hooks.
First, build a mental model
A component is a function with a UI contract. Props are its inputs; children let a caller choose content while the component owns a useful structural responsibility.
- Pass data down through props; do not mutate props.
- Use children to reuse layout without hard-coding every content variant.
- An event prop reports intent to the parent.
- Choose a component boundary around responsibility, not every few lines of markup.
function Panel({ title, children }) {
return <section aria-label={title}><h2>{title}</h2>{children}</section>;
}
function ItemRow({ item, onChoose }) {
return <button onClick={() => onChoose(item.id)}>{item.name}</button>;
}
// <Panel title='Inventory'><ItemRow item={item} onChoose={selectItem} /></Panel>- Parent
The parent supplies data and decides what selecting an item means.
- Row
The row renders the current item and reports a selection event.
- Panel
The panel owns its semantic wrapper while accepting arbitrary content.
Production thinking
Take this beyond the example.
Preserve semantics and labels in reusable controls. A design-system wrapper should not hide keyboard behavior or require a caller to guess its state ownership.
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 · Choose one owner for each fact →