react-drag-drop-container
react-drag-drop-container copied to clipboard
Dragged item component persists if I dont delete them during onDrop or onHit
I have subscribed to onDrop on DragDropContainer. Usually, I delete the dragged node based on some conditions. However, when conditions don't satisfy. I simply return without doing anything. This is causing a problem when drag event occurs subsequently.
The onDrop is called in context to the previous dragged node and also currently dragged node. So, it calls twice. And the calls increases on and on when such dragged node is not deleted in the call.
Can you please suggest me how should I handle this? Thank you very much for such a simple and powerful library.
I had the same problem using onDrop
on DragDropContainer
and I thought I was doing something wrong.
In my case, which was very specific, I could use onHit
on DropTarget
to implement my logic and avoid this issue.
I will try to debug and in case of any progress I will open a Pull Request.
Hi there! I think I'm experiencing the same issue. When I need to use the same Drag element multiple times, the first time everything is fine, but since the 2nd time on, onDrop will fire as many times as that Drag element was used before plus 1 more time. Update: thanks a lot, Guilherme, I also finally fixed it by using onHit instead of onDrop. Whoop.