Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'react-dnd' does not contain an export named 'DragDropContext'

I tried to use react dnd in my react web application. I create a js file call withDnDContext.js. When I compile it, I received an error 'react-dnd' does not contain an export named 'DragDropContext'. My react-dnd version is latest one 9.3.2

This is my withDnDContext.js

import { DragDropContext } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'

export default DragDropContext(HTML5Backend);

Anyone know how to solve this?

like image 485
phoon Avatar asked Jul 26 '19 03:07

phoon


2 Answers

If you use the latest version of react dnd, DragDropContext has been replaced with DndContext. Please see React-DnD V8

My top component looks like this;

import { React } from 'react';
import { DndProvider } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';

export default class MyApp {
    render() {
        return (
            <DndProvider backend={HTML5Backend}>
                <MyComp />
            </DndProvider>
        );
    }
}

The documentation or overview could be really helpful!

like image 94
0stone0 Avatar answered Sep 17 '22 14:09

0stone0


Wrapping HTML5Backend with curly braces solved the problem for me.

import { HTML5Backend } from 'react-dnd-html5-backend'
like image 39
Ruth Mbugua Avatar answered Sep 21 '22 14:09

Ruth Mbugua