monitor.getItem() always returning null
See original GitHub issueDescribe the bug
When I call monitor.getItem()
inside canDrag()
it always returns null
.
Reproduction
Steps to reproduce the behavior:
- Drag around one of the boxes
- Check the console to see the value of
monitor.getItem()
(it’s alwaysnull
)
Expected behavior
I expect the result to be either the value of item
or whatever is returned by begin()
. This is particularly useful in combination with begin()
as some drag events need to be suppressed based on its result.
Desktop (please complete the following information):
- OS: macOS
- Browser: chrome
- Version: 88.0.4324.192 (Official Build) (x86_64)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Is any call monitor.getItemType() return null at the beginDrag ...
what I'm code: import ItemTypes from 'macro/ItemTypes' ; const dragSource = { beginDrag( props , monitor ){ let itemType = monitor.getItemType() ...
Read more >monitor.getDropResult() return null - reactjs - Stack Overflow
monitor. getDropResult() returns null (I look it console. log). It should return object(dragged item) with its position.
Read more >Developers - monitor.getItem() always returning null - - Bountysource
Describe the bug. When I call monitor.getItem() inside canDrag() it always returns null . Reproduction. Live Reproduction. Steps to reproduce the behavior:.
Read more >useDrop - React DnD
If you return an object, it is going to become the drop result and will be available to the drag source in its...
Read more >DropTarget - React-dnd - Breword 文档集合
Do note this is always null when hovering stateless components. ... getItem() does not provide any information about the files or the URLs...
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
The PR goes a little deeper than the problem stated here, but I think this issue brought to light some usability issues with the useDrag() api.
Yeah, I think we could do that - perhaps by returning
null
?