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

  1. 1
    Compound Components: The Idea

    Compound components are several components that only work together and share state internally, like <select> and <option> in HTML.

  2. 2
    Building an Accordion with Shared Context

    The parent Accordion creates a context holding the open item's ID and a toggle function. Child components consume it.

  3. 3
    Identifying Items with a Nested Context

    Each AccordionItem provides its own small context with its id, so Title and Content know which item they belong to without the consumer repeating the ID.

  4. 4
    Grouping Sub-Components (Accordion.Item)

    Attaching the child components as properties of the parent function so they're used as Accordion.Item, Accordion.Title, and Accordion.Content.

  5. 5
    Forwarding Props

    Passing any extra props a wrapper component receives on to the element it renders, using rest/spread syntax.

  6. 6
    Render 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.

  7. 7
    Dynamic Keys with itemKeyFn

    A 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.

  8. 8
    Debouncing 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.

  9. 9
    Choosing a Pattern

    A guide to when each reuse pattern fits.

  10. 10
    Summary