@DragSource(ItemTypes.CHILD, childSource, collectDrag)
@DragTarget(ItemTypes.CHILD, childTarget, collectDrop)
class Child extends Component {
constructor(props) {
this.state = {
children: [1,2,3,4]
}
}
render() {
const { connectDragSource, connectDropTarget, isDragging } = this.props
return connectDragSource(connectDropTarget(
<ul>
{this.state.children.map((child, i) =>
<li key={child}>
<Child index={i} ref={'child/' + i} />
</li>
)}
</ul>
))
}
}
@DragSource(ItemTypes.CHILD, childSource, collectDrag)
@DragTarget(ItemTypes.CHILD, childTarget, collectDrop)
class Child extends Component {
constructor(props) {
this.state = {
children: [1,2,3,4]
}
}
render() {
const { connectDragSource, connectDropTarget, isDragging } = this.props
return connectDragSource(connectDropTarget(
<ul>
{this.state.children.map((child, i) =>
<li key={child}>
<HigherChild index={i} ref={'child/' + i} />
</li>
)}
</ul>
))
}
}
const HigherChild =
DragSource(ItemTypes.CHILD, childSource, collectDrag)(
DragTarget(ItemTypes.CHILD, childTarget, collectDrop)(Child))