React-dnd: Possible to programatically cancel a drag?

Created on 5 Sep 2016  ·  3Comments  ·  Source: react-dnd/react-dnd

Hi folks, thanks for your work on this library. Is it possible to programmatically cancel an in-progress drag? If not, what's the best way to determine if the component has been unmounted at drop-time so we don't try to trigger an action on a (say) deleted item?

wontfix

Most helpful comment

bump

All 3 comments

bump

bump

edit: I wasn't very familiar with the library when I 'bumbed' this.
in case anyone runs into the problem I had, it was the following:

I wanted to cancel a drag if a specific condition was met on drop, so you have to set up two parts:
1 - The receiver has a canDrop method, which returns true or false. You must make your canDrop return false in order to cancel the drag.
2 - Second part is that the I needed some kind of UI behavior to let the user know why this was happening: in this case you have to go to the draggable item and on the endDrag method check if it was successful by doing: if (monitor.didDrop()) which returns true or false. In my case, using the false returned let me show a modal with the information as to why it had failed.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings