由于某种原因,在使用 react-beautiful-dnd 包时,每秒钟的拖动效果都不是很好(见图)
我的 onDragEnd 函数如下所示:
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);
};
拥有返回子组件的 getNodes
不确定这种行为的责任是什么..有什么想法吗?