New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not import DragDropContext in v9.3.2 #1489
Comments
Hi, |
oh thx |
Whats the migration path now that this has been removed? |
Guys, is there any migration guide for the breaking changes in the 9.x version? |
No, You can remind the author to update the document. |
This is what I ended up doing - import { DragDropContext } from "react-dnd";
- import HTML5Backend from "react-dnd-html5-backend";
-
- export const withDragDropContext = DragDropContext(HTML5Backend);
+ import * as React from "react";
+ import HTML5Backend from "react-dnd-html5-backend";
+ import { DndProvider } from "react-dnd";
+
+ export const withDragDropContext = <TProps extends {}>(Component: React.ComponentClass<TProps> | React.StatelessComponent<TProps>) =>
+ {
+ return (props: TProps) => (
+ <DndProvider backend={HTML5Backend}>
+ <Component {...props} />
+ </DndProvider>
+ );
+ }; |
For those out there googling, this might help: THIS DOES NOT WORK import { createDndContext, DndProvider } from "react-dnd";
import Backend from "react-dnd-html5-backend";
// ...
const DndContext = createDndContext(Backend);
// ...
const MyComponent = () => (
<DndProvider backend={Backend} context={DndContext}>
/* ... */
</DndProvider>
); I repeat, THAT DOES NOT WORK Instead do this: import { createDndContext, DndProvider } from "react-dnd";
import Backend from "react-dnd-html5-backend";
// ...
const DndContext = createDndContext(Backend);
// ...
const myComponent = () => (
const managerRef = useRef(DndContext);
<DndProvider backend={Backend} manager={managerRef.current.dragDropManager}>
/* ... */
</DndProvider>
) sources: Dnd code |
how to solve |
As decorator component:
|
Describe the bug
I upgraded dnd from 7.4.5 to 9.3.2, but the browser throw an error:
Attempted import error: 'DragDropContext' is not exported from 'react-dnd'. in 9.3.2
Reproduction
DEMON
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: