question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot have two HTML5 backends at the same time. Conflict with react-dnd

See original GitHub issue

I use react-sortable-tree for my app which supports multiple color themes. I render each tree element with customized ‘generateNodeProps’.

When I change color theme it re-renders the tree.

And everything works perfect without react-dnd. But I have another component which uses react-dnd, so I have to wrap my app to DragDropContextProvider.

<DragDropContextProvider backend={HTML5Backend}>
 ...
</DragDropContextProvider>

and import tree without dnd context. import { SortableTreeWithoutDndContext as SortableTree } from 'react-sortable-tree'; But I still have an error:

HTML5Backend.js:398 Uncaught Error: Cannot have two HTML5 backends at the same time. at HTML5Backend.setup (HTML5Backend.js:398) at DragDropManagerImpl.handleRefCountChange

The above error occurred in the <DropTarget(TreeNode)> component: in DropTarget(TreeNode) (created by Grid) in div (created by Grid) in div (created by Grid) in Grid (created by List) in List in Scrolling(List) (created by AutoSizer) in div (created by AutoSizer) in AutoSizer (created by ReactSortableTree) in div (created by ReactSortableTree) in ReactSortableTree (created by Context.Consumer) in SortableTreeWithoutDndContext (at TreeWithFilters.tsx:618)

App throws error only when I try to expand a tree node (if tree has more than 1 level). For 1 level trees there is no expand buttons and also no errors.

If I disable DragDropContextProvider and import SortableTree with dnd context import SortableTree from 'react-sortable-tree'; i don’t have this error.

I tried to create a codesandbox, but couldn’t reproduce it online in simplified version. Sorry about it.

But maybe some of you had similar problem and you have any ideas, how to solve it.

“react-dnd”: “^7.6.0”, “react-dnd-html5-backend”: “^7.6.0”, “react-sortable-tree”: “^2.6.2”,

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:24

github_iconTop GitHub Comments

7reactions
gusanocommented, Jun 4, 2020

This is pretty annoying and happens with each hot reload

2reactions
dnizeticcommented, Nov 20, 2020

Any fix on this yet. Or a workaround ?

@HavermansStef

My workaround was - place the DnDContext outside of BrowserRouter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React DnD - "Cannot have two HTML5 backends at the same ...
My front is in ReactJS. I have 3 components, first, the container call "Candidates", this component call 2 "CardBoard" components that call " ......
Read more >
Cannot have two HTML5 backends at the same time #3178
Describe the bug I use different react-table draggable in different react-tabs My Index.js contains: import { HTML5Backend } from ...
Read more >
react-dnd - Bountysource
I have an app that uses the HTML5 backend for drop and drop internally. ... For the current time, I've put up a...
Read more >
react-dnd-html5-backend | Yarn - Package Manager
HTML5 backend for React DnD ... See the docs, tutorials and examples on the website: ... chore: apply version (729c984); refactor: use spec...
Read more >
React DnD Cannot have two HTML5 backends at the same ...
Add Class(es) to <html>. Adding Classes. In CodePen, whatever you write in the HTML editor is what goes within the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found