dnd-kit-sortable-tree icon indicating copy to clipboard operation
dnd-kit-sortable-tree copied to clipboard

Does not work with SSR

Open benjick opened this issue 3 years ago • 2 comments

Hey! Great library, thanks for making this!

I'm using it with NextJS but it does not support SSR. I made this change locally: https://github.com/Shaddix/dnd-kit-sortable-tree/pull/9 and then it works if I wrap it with dynamic:

const SortableTreeClient: any = dynamic(() => Promise.resolve(SortableTree), {
  ssr: false,
});

But it still gives me some issues with document if I don't wrap it in dynamic. I think it's related to this line: https://github.com/Shaddix/dnd-kit-sortable-tree/blob/0ee9535b547ad79e8b218b93366a03498691cfc5/src/SortableTree.tsx#L257 but I haven't used portals before so I'm not sure how to solve it.

Cheers

benjick avatar Oct 19 '22 09:10 benjick

Thanks for the PR! I merged it and pushed a version to npm. Personally I haven't used it with SSR, so can't advice much. If something could be changed in a library to make it easier, PRs are more than welcome!

Shaddix avatar Oct 19 '22 11:10 Shaddix

Thanks @Shaddix!

benjick avatar Oct 19 '22 12:10 benjick