react-arborist
react-arborist copied to clipboard
childrenAccessor property doesn't work
When I try to use child elements with another name than "children" there are some bugs:
- not possible to move elements without children
- when we put element with children as a child element of element without children, first one disappear
Example: https://codesandbox.io/s/the-simplest-tree-forked-2ko6gl?file=/src/App.tsx
Both options doesn't work properly:
- childrenAccessor="elements"
- childrenAccessor={(node) => node.elements}
@jameskerr Please provide a working example of tree that have Data with Different Property Names
You're right. This is a bug. The useSimpleTree
hook needs to be updated to accept childrenAccessor props and idAccessor props.
The bug is with initialData. If you use the data prop, and provide your own handlers, the childrenAccessor will work.
The workaround for now is to change your data before passing it to react-arborist.
@jameskerr I like your library and I would like to use it with childrenAccessor feature. So I can try to updated useSimpleTree hook and make a Pull request. How can I install react-arborist for development? (not as a library)
Yes, that would be welcome. Clone the Repo then run yarn && yarn dev
. That will watch for changes to the code and will start the demo site at localhost.
Too complex :( I will wait for your help with fixing this bug