Reputation: 20089
Using https://www.npmjs.com/package/react-beautiful-dnd after reordering some element for the first time, reordering of the previously moved item is not possible and the console prints
Unable to find draggable with id: XXX
Also, when dragging another item the UI get broken and the console prints:
Detected non-consecutive <Draggable /> indexes.(This can cause unexpected bugs) 0, [🔥2], 3, 4, 5
Upvotes: 5
Views: 5009
Reputation: 1583
I got this same error due to a bug in my state logic, where two draggables (in different droppables) had the same draggableId.
Upvotes: 0
Reputation: 20089
SOLUTION
You have to add the key
property to the <Draggable key={uniqueId} ...>
component.
also, please notice:
index
as value for the key
attributeBROKEN
<Draggable draggableId={id} index={index}>
{(provided) => (
...
)}
</Draggable>
FIXED
<Draggable key={uniqueId} draggableId={uniqueId} index={index}>
{(provided) => (
...
)}
</Draggable>
Upvotes: 16