FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Medium

File Explorer

20 mins

Build a component that displays files and directories in a hierarchical tree format.

Requirements:

  1. Display names of files and directories.
  2. Directories:
    • Can contain other directories and files.
    • Should be expandable and collapsible by clicking on them.
    • Should be displayed before files and sorted alphabetically.
    • Can be empty.
  3. Files:
    • Are leaf nodes, cannot be expanded or interacted with.
  4. Indent contents to visually represent hierarchy.
  5. Focus on functionality over styling.
  6. The component should work out-of-the-box in a live React preview (e.g., CodeSandbox/Sandpack).

Code Editor

React Component

00:00
Loading...

Live Preview

See your React component