You may not call monitor.canDrop() inside your canDrop() implementation
See original GitHub issueIn canDrop
, before returning false
, we want to update state to display notification about why it can’t be dropped, but got this error:
Uncaught Error: You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs-drop-target-monitor.html
Is there a way to deal with it or may be a callback function?
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Developers - You may not call monitor.canDrop() inside your ...
In canDrop , before returning false , we want to update state to display notification about why it can't be dropped, but got...
Read more >Checking canDrop() result - react dnd - Stack Overflow
My question now is, when the drop action fails, I want to display a message like "You can't drop this card here because...
Read more >useDrop - React DnD
This method will not be called if canDrop() is defined and returns false . hover(item, monitor) : Optional. Called when an item is...
Read more >DropTarget - React-dnd - Breword 文档集合
Note: You may not call monitor.canDrop() inside this method. The spec offers no methods to handle enter or leave events by purpose. Instead,...
Read more >Rethinking In React DnD - Medium
React DnD is hard to learn if you have never used it before. ... canDrop(),}))export default class PolicyComponents extends React.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zourbuth this issue is confirmed and I think its due to how we bind
this
when we createDropTarget
. I will have to investigate more laterSeems related to https://github.com/react-dnd/react-dnd/issues/265
I will consider possibly writing so canDrop to allow a callback. Or possibly passing the same object to onDragStateChanged. Seems to be a tricky issue
I did a hacky workaround for this issue, since showing a rejection notification in canDrop() was triggered multiple times, so i got dozens of rejection notifications when only one was neccessary.
so i have a variable in state which just records the last success or failure of
canDrop
.then in
onDragStateChanged
if its notisDragging
i check the variable from state, and display the error notif, if it was a failure. For a complete drag action,onDragStateChanged
is triggered once so it works.