Build an accessible project explorer in React that fetches a folder's children only the first time that folder opens. The resting UI is already complete and identical across framework variants.
The starter supplies the complete explorer shell, recursive Node, accessible tree rows, CSS, and loadChildren. Move initialTree into useState, pass the toggle through the recursion, and update the selected branch immutably.
Implement this behavior:
children === null, set loading, show the busy state, await the supplied ~500ms loader, cache its children, expand it, and clear loading.expanded. Do not call the loader again.role="tree", role="treeitem", role="group", aria-expanded, and aria-busy relationships. Rows are native buttons, so Enter and Space work without custom keyboard handlers.Use a recursive updateNode helper and functional state setters so both updates around await build on the latest tree.
children: null means “not loaded.” An array, including an empty one, means “loaded.” Keep that distinction: using expanded as the fetch condition causes repeat requests.
The full solution is part of Premium
Walkthrough, edge cases, complexity notes, and the runnable editor unlock with a Premium subscription.
Submissions are part of Premium
Unlock community code, comments, reactions, and framework-specific approaches.
Build an accessible project explorer in React that fetches a folder's children only the first time that folder opens. The resting UI is already complete and identical across framework variants.
The starter supplies the complete explorer shell, recursive Node, accessible tree rows, CSS, and loadChildren. Move initialTree into useState, pass the toggle through the recursion, and update the selected branch immutably.
Implement this behavior:
children === null, set loading, show the busy state, await the supplied ~500ms loader, cache its children, expand it, and clear loading.expanded. Do not call the loader again.role="tree", role="treeitem", role="group", aria-expanded, and aria-busy relationships. Rows are native buttons, so Enter and Space work without custom keyboard handlers.Use a recursive updateNode helper and functional state setters so both updates around await build on the latest tree.
children: null means “not loaded.” An array, including an empty one, means “loaded.” Keep that distinction: using expanded as the fetch condition causes repeat requests.
The full solution is part of Premium
Walkthrough, edge cases, complexity notes, and the runnable editor unlock with a Premium subscription.
Submissions are part of Premium
Unlock community code, comments, reactions, and framework-specific approaches.
Unlock the solution & editor
Runnable editor + tests
Solve in the browser with instant Jest feedback.
Detailed solutions
Walkthroughs, edge cases, and complexity notes.
Multi-framework variants
React, Vue, Vanilla, Angular — same question, different stacks.