Given an array of file objects, build a component that displays them in a hierarchical tree format.
There are two types of objects – files and directories:
You may assume that the IDs and names within the same directory are unique.
interface FileObject {id: number;name: string;children?: FileObject[];}
Example data:
const fileData = [{id: 1,name: 'README.md',},{id: 2,name: 'Documents',children: [{id: 3,name: 'Word.doc',},{id: 4,name: 'Powerpoint.ppt',},],},];
console.log()
statements will appear here.