I created recursive function for listing all files and folder,I am listing fine but I need path name also how to append please help me.
const treeData = [
{
name: "root",
children: [
{ name: "src", children: [{ name: "index.html" }] },
{ name: "public", children: [] },
],
},
];
const RecursiveTree = (data) => {
data.map((item) => {
console.log(item.name);
if (item.children) {
RecursiveTree(item.children);
}
});
};
RecursiveTree(treeData);
How to get with pathname Expected result
root
root/src
root/src/index.html
children[]should bechildren : [](typo, probably). Also your.mapfunction isn't returning anything, it should. Or useforEachif you're not interested in whatmapreturns.