React Drag and Drop - react-dnd - make component draggable and droppable at the same time (应用两个角色 - 拖放)

React Drag and Drop - react-dnd - make component draggable and droppable at the same time (apply both roles - drag and drop)

我创建了我的应用程序的简化版本。

在这里:https://codesandbox.io/s/quirky-glade-x4h51

当前版本有书签(顶行)和放置它们的地方。 当使用从书签行拖动书签并将其放置到位时,一切正常。 但是,如果用户拖动其中一个地方并想将其移动到某个地方怎么办?

我将 PlaceForChart 组件包装到 DropTarget() 和 DragSource() 并导出包装的组件。但它不能正常工作。 如果删除任何包装器,它将起作用。

目前,当用户尝试拖动任何 PlaceForChart 组件(橙色)时,该组件会更改颜色(如预期),但不会移动。

如何让它发挥作用?

我在 PlaceForChart.tsx 中更改了 key={Math.random()} 并且它开始工作了。还有一些其他问题,但它们与 dnd 行为无关。这是主要的。

工作版本:https://codesandbox.io/s/billowing-wave-tjugx