minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR: Expected drag and drop context

lightandbright opened this issue · comments

I also experience this issue (as some others seem to do). Tried to install react-dnd@13.1.1 still does not work. Also, going back to dnd 13 is a problem as per renzhiVivio comment.

Any chance of a new release addressing this issue? Thanks

@lightandbright package currently depends on the following packages
https://github.com/LouisBrunner/dnd-multi-backend/tree/main/packages/react-dnd-multi-backend

Since this dependency package only supports react-dnd v13, we are unable to increase the version of react-dnd.
The development of react-dnd-multi-backend seems to have stopped for a while, so we are considering to stop using it in future releases.

ERROR: Expected drag and drop context

This error seems to be caused by the package configuration, but I haven't looked into the details yet.
However, it will probably go away if we stop relying on react-dnd-multi-backend, so I will raise the priority of that task.

I really liked this library and wanted to try it out but I am getting this error.

I had react-dnd and react-dnd-html5-backend v11.1.3 and got this error, I updated both to v14.0.5 and still getting this error.

@mkamalkayani Thanks for the report.

This time I have reviewed the package dependencies and modified them to work with the latest react-dnd.
I also changed react-dnd to peerDependencies so that it will not be installed automatically.
Since it is now published as an alpha version, can you please install it with the following command and check if it works?

npm remove react-dnd-html5-backend
npm install react-dnd@latest
npm install @minoru/react-dnd-treeview@alpha

@minop1205 Yes, by following your suggestions it works. Thanks.

There is one thing worth consideration. I have a <DndProvider backend={HTML5Backend}> at the top level of my application. If I comment out this provider then I again get this error. Based on this I assume that a DndProvider has be present at a top level for this to work.

@mkamalkayani Thanks for the confirmation.

@minoru/react-dnd-treeview has a <DndProvider> inside the component, which seems to conflict with it.

Considering the various use cases, it might be better not to have <DndProvider> inside this package.

I have just published a version that removes this <DndProvider> from the package.
Now that we have updated the alpha version, you can install it with the following command

npm install @minoru/react-dnd-treeview@alpha

If you already have <DndProvider> at the top level, you can use it as-is, so give it a try.

@minop1205 Works perfectly. Thanks for the update.

I would agree, not including the DndProvider inside the package will give the user flexibility to either use the existing DndProvider or add a new one.

Thank you very much.

Removing the DnDProvider from the component, it will not be compatible with past versions, so a major version upgrade will be required. Please wait a little bit until the official release, as we need to modify the documentation and so on.

v2 is released today.
This version does not include DndProvider, so we can share DndProvider with other components.
Please see the README for details.