atlassian / pragmatic-drag-and-drop

Fast drag and drop for any experience on any tech stack
https://atlassian.design/components/pragmatic-drag-and-drop
Other
7.45k stars 133 forks source link

Docs: Drag Preview #28

Closed MrNiceRicee closed 1 month ago

MrNiceRicee commented 1 month ago

Hello there!

I was wondering the choice for the drag preview to use ReactDom.render() instead of the ReactDom.createRoot().render()

got a warning in react that it'll run in react 17 instead of react 18

// in the docs
    setCustomNativeDragPreview({
      render({ container }) {
        ReactDOM.render(<Preview item={item} />, container);
        return function cleanup() {
          ReactDOM.unmountComponentAtNode(container);
        };
      },
      nativeSetDragImage,
    });

vs

    setCustomNativeDragPreview({
    render: ({ container }) => {
      const root = ReactDOM.createRoot(container);
      root.render(<Preview item={item} />);
      return () => root.unmount();
    },
      nativeSetDragImage,
    });

thank you again for making a great tool!

alexreardon commented 1 month ago

Either approach is fine. But you will most likely want to use a portal 😇