How can I console log in my file where I have the drop area, the id of the node that I am moving (draggable item). I believe I am supposed to use monitor.getItem()
, as specified in the documentation, but I don't understand it,
I have a ref={drag}
on my dragable and ref={drop}
on my droppable node.
Draggable item:
const [{ isDragging }, drag] = useDrag({
item: { type: 'TODO_ITEM' },
collect: monitor => ({
isDragging: !!monitor.isDragging()
}),
drag: () => {
console.log('dragging')
}
})
Drop area
const [{ isOver, canDrop }, drop] = useDrop({
accept: 'TODO_ITEM',
collect: mon => ({
isOver: !!mon.isOver(),
canDrop: !!mon.canDrop()
}),
drop: monitor => {
console.log(monitor)
// monitor only returns { type: 'TODO_ITEM' }
}
})