我正在构建一个多级可嵌套拖放列表。每个嵌套列表只需要允许在其内部拖动。type
这需要为DragSource
and设置运行时DropTarget
。
编译时type
声明有效但受到限制
export default flow(
DropTarget(ItemLevel.ROOT, target, connect => ({
connectDropTarget: connect.dropTarget(),
})),
DragSource(ItemLevel.ROOT, source, (connect, monitor) => ({
connectDragSource: connect.dragSource(),
isDragging: monitor.isDragging(),
})),
)(MenuItem)
运行时type
声明似乎有效,但在拖动时会引发错误
export const getGroupMenuItem = menuGroupId => flow(
DropTarget(menuGroupId, target, connect => ({
connectDropTarget: connect.dropTarget(),
})),
DragSource(menuGroupId, source, (connect, monitor) => ({
connectDragSource: connect.dragSource(),
isDragging: monitor.isDragging(),
})),
)(MenuItem)