Closed
Description
Bug
If app is using external react-dnd (from CDN), the SortableTreeWithoutDndContext does not work. It's because react-sortable-tree uses internal stuff (React Context Consumer) imported from "react-dnd/lib/DragDropContext". App wraps the root component into DragDropContext (imported from external react-dnd) because it uses several libraries which use react-dnd and when it tries to use SortableTreeWithoutDndContext, depending on app configuration 2 things might happen:
- either it won't work because "react-dnd/lib/DragDropContext" would be considered external by app and no such file is present in built react-dnd on CDNs (making it available won't work either)
- or it won't work because react-dnd/lib/DragDropContext will be bundled into the app's bundle which means that there'll be 2 copies of it in the page (one in app's bundle, one in react-dnd from CDN), effectively creating 2 different instances of React Context Consumer (only the one in app's bundle will be initialized with dragDropManager).
Ideas how to fix this:
- Don't use Consumer from react-dnd/lib/DragDropContext - glancing at the code this might not be easy as it receives dragDropManager from it and uses it a lot.
- Maybe file a feature request for react-dnd to export the Consumer as standard API so that react-sortable-tree can then use
import { Consumer } from "react-dnd"
. - ?
Edit:
Demo for simulation in https://github.com/mareolan/react-sortable-tree-issue-459
Metadata
Metadata
Assignees
Labels
No labels