Created
January 9, 2021 18:30
-
-
Save samilkahraman/65d73b18c41037b7b36cc75c53c44fd3 to your computer and use it in GitHub Desktop.
Ağacın kategori şeklinde gözükmesi için.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const menuItem = (obj, depth) => { | |
let line = ""; | |
for (let i = 0; i < depth; i++) { | |
line += " — "; | |
} | |
return ( | |
<MenuItem value={obj.id} onChange={handleMultiple}> | |
{line} {obj.name} | |
</MenuItem> | |
); | |
}; | |
const writeOrdered = (obj, depth) => { | |
const element = menuItem(obj, depth); // root | |
allCategoriesOrdered.push(element); | |
if (obj.children.length > 0) { | |
depth++; | |
obj.children.forEach((category) => { | |
writeOrdered(category, depth); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment