-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce2171e
commit 46ea52d
Showing
1 changed file
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
import { DragDropContext } from 'react-dnd'; | ||
import HTML5Backend from 'react-dnd-html5-backend'; | ||
import React from 'react'; | ||
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; | ||
|
||
export default DragDropContext(HTML5Backend); | ||
const withDNDContext = (component) => { | ||
const DNDConnector = (props) => { | ||
const { DragDropContext } = props.reactDnd; | ||
const HTML5Backend = props.reactDndHtml5Backend.default; | ||
|
||
const DNDSubblocks = React.useMemo( | ||
() => DragDropContext(HTML5Backend)(component), | ||
[DragDropContext, HTML5Backend], | ||
); | ||
|
||
return <DNDSubblocks {...props} />; | ||
}; | ||
return injectLazyLibs(['reactDnd', 'reactDndHtml5Backend'])(DNDConnector); | ||
}; | ||
|
||
export default withDNDContext; |