Group by Category
Write the code, see it run, pass the checks.
The problem
- easy
- Code
The Pantry component gets an items prop: a list of { name, category } objects (the preview uses Apple in Fruit, Carrot in Vegetable, Banana in Fruit, Milk in Dairy and Leek in Vegetable). Show one group per category, in the order each category first appears: a heading with just the category's name, then a list of its items' names, in their original order. Give each list an accessible name that is its category, for example with aria-label or aria-labelledby pointing at its heading, so the checks can find "the Fruit list". Work the groups out from the prop, so any categories passed in get their own group.
Your code must pass
- Shows a heading per category, in order of first appearance
- Lists each category's items under it, in their original order
- Works for any items passed in