Skip to content

Instantly share code, notes, and snippets.

@samilkahraman
Created January 9, 2021 18:30
Show Gist options
  • Save samilkahraman/65d73b18c41037b7b36cc75c53c44fd3 to your computer and use it in GitHub Desktop.
Save samilkahraman/65d73b18c41037b7b36cc75c53c44fd3 to your computer and use it in GitHub Desktop.
Ağacın kategori şeklinde gözükmesi için.
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