我想将一个元素从另一个元素移到另一个元素DragDropContext
:
我有一个://sidebar.js
<DragDropContext onDragEnd={() => console.log('sidebar end drag')}>
<Droppable droppableId="sidebar">
{provided =>
<Draggable
ref={provided.innerRef}
{...provided.draggableProps}
{...other props}
>
I can be dragged
</Draggable>
}
</Droppable>
</DragDropContext >
// footerDroppable.js
<Droppable droppableId="footerDrop">
{provided =>
<Draggable
ref={provided.innerRef}
{...provided.draggableProps}
{...other props}
>
I'm a footer drag
</Draggable>
}
</Droppable>
</DragDropContext >
// 结构
<div>
<Sidebar> // first drag context
<div>
<footer>
<other elements />
<FooterDroppable /> // second drag context
<footer>
<div/>
我可以将可拖动的元素从页脚移动到侧边栏/反之亦然?
当然,我可以只移动DragDropContext
两个组件的父级(我知道该怎么做),但是除了有一个父级之外还有其他DragDropContext
方法吗?
PS上面的代码不是确切的结构/代码,而是更像一个原型,所以你可以可视化,因为我正在开发一个更大的应用程序。