Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SortableTreeWithoutDndContext does not work #788

Open
zourbuth opened this issue Aug 27, 2020 · 10 comments
Open

Using SortableTreeWithoutDndContext does not work #788

zourbuth opened this issue Aug 27, 2020 · 10 comments

Comments

@zourbuth
Copy link

rstwithoutdndcontext

There are two DnDs in a page.
One for the RST with external nodes, and the other for the tab swapping.
We place <DndProvider /> in top level component and
use SortableTreeWithoutDndContext in child component
to avoid two HTML backends issue.

It seems the RST renders nothing or returns null as the dragDropManager is undefined.

const SortableTreeWithoutDndContext = props => (
<DndContext.Consumer>
{({ dragDropManager }) =>
dragDropManager === undefined ? null : (
<ReactSortableTree {...props} dragDropManager={dragDropManager} />
)
}
</DndContext.Consumer>
);

Is there a workaround to deal with this issue?
Thank You.

@zourbuth
Copy link
Author

zourbuth commented Sep 7, 2020

Any update?
It seems there is no activity for this repository for weeks.
Is this still maintained?

@zli-aa
Copy link

zli-aa commented Sep 21, 2020

@zourbuth You need to wrap your component with the DndProvider.

<DndProvider backend={HTML5Backend}>
    <SortableTreeWithoutDndContext />
</DndProvider>

ref: https://github.com/frontend-collective/react-sortable-tree/blob/master/stories/touch-support.js

@zourbuth
Copy link
Author

zourbuth commented Sep 21, 2020

@zli-aa, we did. We wrap it in top level component.
But dragDropManager always undefined and it makes RST renders null.

dragDropManager === undefined ? null : (

@aliakakis
Copy link

@zli-aa it worked for us but I really do believe as @zourbuth mentioned that this repo seems to be unmaintained...

@drewpc
Copy link

drewpc commented Oct 16, 2020

@zourbuth I had the same problem and it was because I ended up with two copies of react-dnd in my final Webpack bundle, one that I was importing and the other that react-sortable-tree imported. Because DndContext is a singleton, having two copies means there are two singletons! I resolved the issue for myself by ensuring Webpack resolved the react-dnd package to a single, top-level installation of react-dnd.

https://webpack.js.org/configuration/resolve/#resolvealias

@Nauss
Copy link

Nauss commented Oct 28, 2020

I was having the same problem for months now and none of the solutions worked except for @drewpc 's one #788 (comment) ! Thanks :)

If anyone is interested, my webpack modification looks like this:

  resolve: {
    ...
    alias: {
      'react-dnd': path.resolve(__dirname, '../node_modules/react-dnd'),
    },
  },

@malestroms
Copy link

malestroms commented Jan 27, 2021

I just install and configure webpack just for try @drewpc solution but it didn't work for me, I've tried @Nauss just like that :( didn't work either, anyone have suggestions please?

btw: In my case I have a component that use react-sortable-tree and other that I'm trying to use basic HTML Drag and drop using draggable="true", but it doesn't work due the this lib, If I stop loading everything works :/ so I assume the issue is related

@PCPbiscuit
Copy link

None of the suggestions above seem to have helped. Tried resolving and also whenever I use SortableTreeWithoutDndContext it just doesn't render anything.

@minhdtb
Copy link

minhdtb commented Oct 5, 2022

I faced the same issue with React 18 and typescript

@GabrielMil
Copy link

GabrielMil commented Dec 25, 2022

@minhdtb Were you able to fix the problem? Using React 18 and typescript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants