Components and propsPath 2/21
Components & propsState & eventsConditional renderingAccessibility
Prerequisites are suggestions only. Every challenge stays open.
FAQ Accordion
Build an accessible accordion from a data array and a reusable FaqItem component.
Requirements
- Track the open FAQ by its stable
id; do not store the entire object.
- Render every item with
map and a stable key.
- Allow at most one answer to be open at a time.
- Clicking an open item should close it.
- Extract an
FaqItem component whose behavior is controlled through props.
- Add
aria-expanded and aria-controls to each trigger.
Stretch goal
Support moving between accordion triggers with the up and down arrow keys.