react-dnd / react-dnd-html5-backend

HTML5 backend for React DnD [Legacy Repo]
MIT License
145 stars 97 forks source link

Conflict: Check for dropTargetIds in handleTopDrop() #33

Closed chrisbuttery closed 7 years ago

chrisbuttery commented 8 years ago

This PR is a fix to address issue #32

Check dropTargetIds exists and has a length. If so, do something.

chrisbuttery commented 8 years ago

Hello, I'm just wondering if we could add this conditional to check the existence and length of dropTargetIds.

If it doesn't exists or have and ids, do nothing.

acusti commented 7 years ago

I’ve run into this same issue. It’s very intermittent, and I have no idea what causes handleTopDrop to get invoked when targetIds doesn’t exist, but whatever the cause, the result is we get the Uncaught Invariant Violation: Expected targetIds to be an array error.

@darthtrevino Does the approach in this PR look safe as a way to harden the event handling, even if it doesn’t address the root cause?

darthtrevino commented 7 years ago

This looks like it may be an initial state issue. this.dropTargetIds is never set in the constructor. Would adding this.dropTargetIds = [] to the constructor solve this?

darthtrevino commented 7 years ago

If this issue persists in the newest version, let me know, and we can work a solution out in the monorepo