react-sortablejs icon indicating copy to clipboard operation
react-sortablejs copied to clipboard

[bug] Throws removeNode error on nested sortable

Open edparsons opened this issue 5 years ago • 3 comments

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

  1. Drag item from one list to another
  2. 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.

edparsons avatar Apr 24 '20 05:04 edparsons

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

karldanninger avatar Apr 24 '20 14:04 karldanninger

related #23. It's the reason why I'm yet to set an example of nested sortables.

waynevanson avatar Apr 27 '20 08:04 waynevanson

@waynevanson this example seems to work?: https://codesandbox.io/s/react-sortable-js-nested-tu8nn?file=/src/App.js:2083-3673

nickvanhooydonk avatar Nov 12 '20 18:11 nickvanhooydonk