React-dnd: TypeError: React.createContext is not a function

Created on 3 Jul 2018  ·  3Comments  ·  Source: react-dnd/react-dnd

I am getting a TypeError: React.createContext is not a function when trying to add DragDropContext to component. I am using React v15.6.1 and I am wondering if it's required to use React v16 to use react-dnd since Context introduced in React v16.

Here is my component where I am trying to add DragDropContext.

import React, {Component} from 'react';
import FormSpace from './FormSpace';
import TextItem from './TextItem';
import HTML5Backend from 'react-dnd-html5-backend';
import { DragDropContext } from 'react-dnd';


class AdvancedFormRnd extends Component {
    render() {
        return (
            <div className="container">
                <div className="row">
                    <div className="col-sm-8">
                        <FormSpace/>
                    </div>
                    <div className="col-sm-4">
                        <TextItem/>
                    </div>
                </div>
            </div>
        )

    }
}
export default DragDropContext(HTML5Backend)(AdvancedFormRnd);

<TextItem/> is the component which I want to make Draggable and <FormSpace/> is Droppable component.

This happens if I just import DragDropContext from react-dnd.

Most helpful comment

Update react version to 16 or change react-dnd version to 3.0.2.

Refer this link for latest changes of dnd: https://github.com/react-dnd/react-dnd/releases/tag/v4.0.0

All 3 comments

Update react version to 16 or change react-dnd version to 3.0.2.

Refer this link for latest changes of dnd: https://github.com/react-dnd/react-dnd/releases/tag/v4.0.0

Thanks @Mangaraju-Velpula. I forgot to check the changelog. Now it's clear. Is there any separate documentation for version 3.0.2 or the current documentation is okay with version 3.0.2?

Current documentation is enough.

Was this page helpful?
0 / 5 - 0 ratings