dazzle icon indicating copy to clipboard operation
dazzle copied to clipboard

DragDropContext HMLT5Backend at top level of my app

Open khelkun opened this issue 6 years ago • 6 comments

Dazzle wraps its Dashboard Component with react-dnd's DragDropContext(HMLT5Backend)

I wish to use Dazzle in my application but also use react-dnd in another part of my component hierarchy which is not under the Dashboard component of Dazzle. So I would need to wrap my top most component in my React application with DragDropContext(HMLT5Backend). But whatever I do I will get the "Error: Cannot have two HTML5 backends at the same time" from react-dnd.

I think I'll not be able to do this without modifying Dazzle to not instantiate the DragDropContext in the Dashboard component. Am I right or is there a workaround that would not imply to modify Dazzle?

khelkun avatar Sep 18 '17 11:09 khelkun

I'm afraid there is no workaround I can think of right now since dazzle is coupled with react-dnd. Sorry about that!

Raathigesh avatar Sep 18 '17 12:09 Raathigesh

For my usage I declared a new component in dazzle called DashboardNoDndContext (that doesn't instantiate the DragDropContext) and rebuilt and it seems to be enough for my need. Obviously I also exported this DashboardNoDndContext in the index.js (not default export). I can do a pull request for that: exporting a second Dashboard component that let the responsability of creating the DragDropContext to the user of Dazzle. What do you think ? (I'm also not sure how to call this alternate Dashboard component)

khelkun avatar Sep 18 '17 12:09 khelkun

That seems like a neat solution! Feel free to send a PR! how about DashboardWithoutDndContext ?

Raathigesh avatar Sep 18 '17 13:09 Raathigesh

Thanks I'll go for this PR Ok for the component name. I'll see if I can just keep one Dashboard component definition and export 2 distinct symbols for the same module: one wrapped/decorated by DragDropContext and the other without this wrapping.

khelkun avatar Sep 18 '17 13:09 khelkun

Awesome! Two exports from the same file would be nice. We could remove the decorator and have an export which wraps the dashboard component with the Dnd context as you mentioned above.

Raathigesh avatar Sep 18 '17 13:09 Raathigesh

Hello, is any timeline for a release that will include this fix?

armckenzie avatar Feb 15 '19 00:02 armckenzie