question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

monitor.getItem() always returning null

See original GitHub issue

Describe the bug When I call monitor.getItem() inside canDrag() it always returns null.

Reproduction

Live Reproduction

Steps to reproduce the behavior:

  1. Drag around one of the boxes
  2. Check the console to see the value of monitor.getItem() (it’s always null)

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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
darthtrevinocommented, Mar 4, 2021

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.

0reactions
darthtrevinocommented, Mar 4, 2021

Yeah, I think we could do that - perhaps by returning null?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found