Skip to content

Commit

Permalink
fix: check for optionality to handle race condition when dragging
Browse files Browse the repository at this point in the history
A race condition can result in the item being undefined in `getItem()`.
  • Loading branch information
prashanthvdckap authored Apr 3, 2024
1 parent dc93789 commit 4dbd487
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/lib/get-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ export const getItem = (
if (!selector.zone || selector.zone === rootDroppableId) {
const item = data.content[selector.index];

return { ...item, props: dynamicProps[item.props.id] || item.props };
return item?.props
? { ...item, props: dynamicProps[item.props.id] || item.props }
: undefined;
}

const item = setupZone(data, selector.zone).zones[selector.zone][
selector.index
];

return { ...item, props: dynamicProps[item.props.id] || item.props };
return item?.props
? { ...item, props: dynamicProps[item.props.id] || item.props }
: undefined;
};

0 comments on commit 4dbd487

Please sign in to comment.