call(back)
FrontendmediumSign in to star problems

File Explorer

Build a file explorer for the nested data in the starter.

Requirements

  • Directories come before files at every level; within each group entries are alphabetical.
  • A directory is a button that expands or collapses its contents; collapsed directories render nothing beneath them.
  • Nesting is unlimited and each level is indented.
  • Expanding one directory does not affect any other.
  • The button reports its state with aria-expanded.

Hints

Hint 1

A component that renders a list of entries and calls itself for a directory's children handles any depth.

Hint 2

Keep the expanded directory ids in a Set in the top-level component and pass it down with a toggle callback.

Hint 3

Sort a copy of each level's entries: directories first, then by name.

Asked at