react-arborist
react-arborist copied to clipboard
Is it possible to have different childrenAccessor?
I have a data object with different children elements. Is it possible to have different childrenAccessor?
example: level 2 => children_name_entries, level 3 => children_another_name_entries
export const data = [
{ id: "1", name: "Random" },
{ id: "2", name: "Random" },
{
id: "3",
name: "Random",
children_name_entries: [
{ id: "1", name: "Random" },
{ id: "2", name: "Random" },
{ id: "3", name: "Random", children_another_name_entries: [
{ id: "1", name: "Random" },
{ id: "2", name: "Random" },
{ id: "3", name: "Random" }
] }
];
Thanks a lot :)
Maybe, you can pass a function to the childrenAccessor prop. That function gives you the node from your data. If you can figure out which level your node is, you can return props with different children.