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.

"Uncaught Invariant Violation: Expected to find a valid target." after cancelling a drag into the react sortable tree

See original GitHub issue

I discovered this issue while integrating react-sortable-tree into my app, but was able to easily reproduce with one of the examples in the storybook.

https://codesandbox.io/s/xzoq6xprlz

Drag the “baby rabbit” box to the React Sortable Tree area, move it around so that it registers with the React Sortable Tree, then move the box out of the React Sortable Tree area such that the placeholder turns red, then release the box outside of the React Sortable Tree area.

Screen Shot 2019-05-31 at 1 12 04 PM

This will cause the Console to fire with this error.


**browser.js:38 Uncaught Invariant Violation: Expected to find a valid target.
    at invariant (https://xzoq6xprlz.codesandbox.io/node_modules/invariant/browser.js:38:15)
    at DragDropMonitorImpl.canDropOnTarget (https://xzoq6xprlz.codesandbox.io/node_modules/dnd-core/lib/cjs/DragDropMonitorImpl.js:67:9)**
    at DropTargetMonitorImpl.canDrop (https://xzoq6xprlz.codesandbox.io/node_modules/react-dnd/lib/cjs/DropTargetMonitorImpl.js:24:41)
    at nodeDropTargetPropInjection (https://xzoq6xprlz.codesandbox.io/node_modules/react-sortable-tree/dist/index.cjs.js:2367:28)
    at DragDropContainer.getCurrentState (https://xzoq6xprlz.codesandbox.io/node_modules/react-dnd/lib/cjs/decorateHandler.js:116:29)
    at DragDropContainer._this.handleChange (https://xzoq6xprlz.codesandbox.io/node_modules/react-dnd/lib/cjs/decorateHandler.js:45:39)
    at handleChange (https://xzoq6xprlz.codesandbox.io/node_modules/dnd-core/lib/cjs/DragDropMonitorImpl.js:27:21)
    at dispatch (https://xzoq6xprlz.codesandbox.io/node_modules/redux/lib/redux.js:220:7)
    at Object.eval [as endDrag] (https://xzoq6xprlz.codesandbox.io/node_modules/dnd-core/lib/cjs/DragDropManagerImpl.js:67:21)
    at HTML5Backend.handleTopDragEndCapture (https://xzoq6xprlz.codesandbox.io/node_modules/react-dnd-html5-backend/lib/cjs/HTML5Backend.js:145:31)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
karibertilscommented, Jan 10, 2022

+1 Also getting this

1reaction
samhatoumcommented, Mar 12, 2021

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Uncaught Invariant Violation: Expected to find a valid target ...
"Uncaught Invariant Violation: Expected to find a valid target." after cancelling a drag into the react sortable tree.
Read more >
React DnD Expected to find a valid target - Stack Overflow
In order to trigger the error just drag & drop the first item into another one. Notice that if you drag & drop...
Read more >
React Dnd Expected To Find A Valid Target - ADocLib
Uncaught Error: Invariant Violation: Expected to find a valid target.n ... to find a valid target. after cancelling a drag into the react...
Read more >
cuong-react-sortable-tree - npm
... react-sortable-tree to fixed error: "Uncaught Invariant Violation: Expected to find a valid target." A React component for Drag-and-drop ...
Read more >
How to implement drag and drop in React with React DnD
It will automatically require the dropzone to allow only one file to get accepted. isDragActive is set if the files are dragged above...
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