For some reason every second drag is not performing very well when using the react-beautiful-dnd package (see image)
my onDragEnd function is looking like this:
const onDragEnd = result => {
if (!result.destination) {
return;
}
if (
result.destination.droppableId === result.source.droppableId &&
result.destination.index === result.source.index
) {
return;
}
const draggedItem = list[result.source.index];
list.splice(result.source.index, 1);
list.splice(result.destination.index, 0, draggedItem);
/** Firebase update */
dbCon.once('value', function(snapshot) {
snapshot.forEach(function(child) {
list.map((listChild, index) => {
if (listChild.props.draggableId === child.key) {
child.ref.update({ position: index });
}
});
});
});
setList(getNodes);
};
Having getNodes that is returning child components
Not sure what the responsible is for this behaviour.. any ideas?