Skip to content

Commit

Permalink
fix: prevent crash in determineDropResult (#1281) (#1367)
Browse files Browse the repository at this point in the history
When target is undefined, determineDropResult crashes. I was not able to determine why `registry.getTarget` would return undefined. The issues happens sometimes when I am dragging and dropping quickly. Perhaps the drop target is getting unmounted as mentioned in #31.

I am happy to dig deeper if someone can point me in the right direction regarding which files might be relevant.

This fixes #1281.
  • Loading branch information
raineorshine authored and darthtrevino committed Jun 4, 2019
1 parent 884c6ff commit 5c8af9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/dnd-core/src/actions/dragDrop/drop.ts
Expand Up @@ -50,7 +50,7 @@ function determineDropResult(
monitor: DragDropMonitor,
) {
const target = registry.getTarget(targetId)
let dropResult = target.drop(monitor, targetId)
let dropResult = target ? target.drop(monitor, targetId) : undefined
verifyDropResultType(dropResult)
if (typeof dropResult === 'undefined') {
dropResult = index === 0 ? {} : monitor.getDropResult()
Expand Down

0 comments on commit 5c8af9a

Please sign in to comment.