Wrap React-App with React-DND HTML5Backend

Create a component which will wrap react children with React-DND HTML5Backend.

DragAndDropProvider.tsx
import React from 'react'
import { DragDropContext } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'

export class DragAndDropProvider extends React.Component<{}, {}> {

  constructor (props: any) {
    super(props)
  }

  render (): JSX.Element {
    return (
      <div>
        {this.props.children}
      </div>
    )
  }
}

export default DragDropContext(HTML5Backend)(DragAndDropProvider)

Wrap the AppRoot with above created DragAndDropProvider.

Last updated