-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the path to a leaf of the tree? #37
Comments
I just solved it like this inside the crawl Iteratee callback, but I'm not sure if it's the best way: crawl(tree, (node, context) => {
// add path to each node
node.path = context.cursor.stack.xs.reduce((result, item) => {
if (item.node) {
result.push(item.node);
}
return result;
}, []);
}) |
@arielger Thanks 😄 I was initially exposing a That said, it's a pretty common use case, so I guess I will mention how to do that in the |
Added an FAQ section in the |
@ngryman Sadly, this doesn't seem to work anymore: https://codesandbox.io/s/tree-crawl-path-fc2hv6?file=/src/App.js |
I want to get the path to a leaf inside the tree. Do you have any recommended way to do this?
Similar to this method https://github.com/joaonuno/tree-model-js#get-the-node-path
Thanks for your work on this, great library 👌
The text was updated successfully, but these errors were encountered: