Recursive file tree
Model and render nested folders with durable expansion state.MediumComponent Patterns
40 min58.3% acceptance
Description
Implement an accessible file explorer from recursive data. Folders can expand independently, active files are clearly indicated, and expansion state survives data refreshes.
Requirements
Every supplied file and folder is rendered at its correct nesting level.
Expanding or collapsing one folder does not change the expansion state of its siblings.
Expanded folder IDs remain expanded after rerendering with refreshed node objects.
The explorer exposes tree and treeitem semantics together with aria-expanded on folders.
Selecting a file exposes a single visibly and programmatically active tree item.
Nested folder
Input
Expand src, then components
Expected output
Both folders remain expanded and their children are visible
Constraints
Support arbitrary nestingUse stable identifiers for expansion stateExpose tree semantics
Hints
Hint 1
Create one node component that can render its children by invoking the same component at the next depth.
Hint 2
Store expanded folder identifiers separately from node objects so refreshed data does not reset the interface.
Hint 3
Derive each node's tree semantics, selection, and expansion attributes from its type and current state.
recursiontree viewstate modeling