Newtons
  • LANDING PAGE
  • General principles
  • Questions
  • React
  • AWS
  • Typescript
  • Testing (Jest)
    • Testing wisdom
    • Definitions
  • Wallaby
  • VsCode
  • Gitlab
  • Material ui
  • Yarn
  • Stripe
  • Keygen
  • React DND Typescript
    • Wrap React-App with React-DND HTML5Backend
  • React Virtualisation
  • Electron
    • Multiple rapid touches in Electron's <webview> cause input freeze
  • Storybook
  • Webpack
  • Serverless
  • Dynamo DB
    • Deploy table after changing key schema
  • S3
  • Route 53
  • API Gateway
  • SSM parameter
  • Cloud watch
  • Cloud front
  • Cloud formation
  • React testing library
  • CSS
  • Usability
  • How to use the KMS
    • When to create a new page
    • What to put in
    • Important information for a bug/issue
    • Important information for an article
    • References
    • When to create a new group
Powered by GitBook
On this page
  1. React DND Typescript

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.

index.ts
import DragAndDropProvider from './DragAndDropProvider'

.....
/** Render a component tree composed with the DragAndDropProvider. */
const render = (AppRoot: typeof App) => {
  ReactDOM.render(
    React.createElement(HotContainer, {},
      React.createElement(Router, { history },
        React.createElement(DragAndDropProvider, {},
          React.createElement(AppRoot, {}, null)
        )
      )
    ),
    document.getElementById('app')
  )
}
PreviousDefinitionsNextMultiple rapid touches in Electron's <webview> cause input freeze

Last updated 6 years ago