react-sortablejs
react-sortablejs copied to clipboard
[bug] Throws removeNode error on nested sortable
Describe the bug I drag an item from one ReactSortable to another and on the setList callback set state and then this error happens. If I wrap the setState in a setTimeout I do not get the error but there is a flicker of the item going back to the original list then back to the new list.
To Reproduce Steps to reproduce the behavior: https://codesandbox.io/s/currying-feather-oc95c?file=/src/styles.css
- Drag item from one list to another
- See error
Expected behavior No error
Information react-sortable = ^2.0.11 react = ^16.9.0
Additional context I will try to remove the component outside my application and if the problem persists I can post it here so others can repro
Error:
react-dom.development.js:10073 Uncaught DOMException: to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
I just dealt with this last night. What I did to stop this error from happening is each nested ReactSortable has its own component and its own state const [list, setList] = useState(inheritedListState).
I hope this might help you
related #23. It's the reason why I'm yet to set an example of nested sortables.
@waynevanson this example seems to work?: https://codesandbox.io/s/react-sortable-js-nested-tu8nn?file=/src/App.js:2083-3673