foundation
Composition
Prefer component composition, slots, children, and explicit ownership over inheritance-style reuse.
React favors composition: parents pass children, slots, or render functions instead of giant prop lists. `children`, nested components, and hooks replace class inheritance for most reuse. Configuration props (`variant`, `size`) work for design systems; behavior reuse often moves into custom hooks.
Explicit composition keeps ownership visible — who provides data, who renders chrome, who handles events. It scales better than monolithic components with dozens of boolean flags.
On interviews, explain the concept with a concrete example and name the behavior interviewers probe.
Common pitfalls include hiding data flow, over-splitting components, and putting side effects in render.
The trade-off is often clarity versus reuse or explicit props versus convenience.
Checklist:
- Prefer children and small focused components.
- Extract behavior into hooks.
- Avoid prop explosion and boolean prop matrices.