Problem
Build a file explorer that renders a nested folder structure as a collapsible tree.
Requirements
- Render folders and files from a nested JSON structure.
- Click a folder to expand/collapse its children.
- Folders show a different icon than files; only folders can contain children.
- (Bonus) Add a new file/folder under a folder, and delete a node.
- (Bonus) Lazy render children only when expanded.
Hints / Approach
- Model:
{ name, isFolder, children: [] }. Render recursively with aNodecomponent. - Keep expand state per-node (local state in each
Node, or a map keyed by id in the parent). - For add/delete, mutate an immutable copy and lift state up, or use a reducer keyed by node id.