10 entries · 15-question quiz
React Patterns & Best Practices
React ↔ Angular reference. React examples use React 19 + TypeScript. Angular examples use modern Angular (standalone components, signals, inject(), @if/@for).
Test yourself
15 questions
- 1Compound Components: The Idea
Compound components are several components that only work together and share state internally, like
<select>and<option>in HTML. - 2Building an Accordion with Shared Context
The parent
Accordioncreates a context holding the open item's ID and a toggle function. Child components consume it. - 3Identifying Items with a Nested Context
Each
AccordionItemprovides its own small context with itsid, soTitleandContentknow which item they belong to without the consumer repeating the ID. - 4Grouping Sub-Components (
Accordion.Item)Attaching the child components as properties of the parent function so they're used as
Accordion.Item,Accordion.Title, andAccordion.Content. - 5Forwarding Props
Passing any extra props a wrapper component receives on to the element it renders, using rest/spread syntax.
- 6Render Props
A component receives a function (often as
children) and calls it to render part of its output. The component controls when and with what data; the consumer controls how it looks. - 7Dynamic Keys with
itemKeyFnA function prop that tells a generic list how to get a unique key from each item, since the list doesn't know the item's shape.
- 8Debouncing User Input
Debouncing delays an action until the user stops triggering it for a set time, e.g. filtering only after typing pauses for 500 ms.
- 9Choosing a Pattern
A guide to when each reuse pattern fits.
- 10Summary