Skip to content

Commit 2b77252

Browse files
committed
missed a callback
1 parent b16e64b commit 2b77252

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/features/layers/LayerList.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,19 @@ const LayerList = () => {
130130
[dispatch],
131131
)
132132

133-
const handleDragEnd = ({ active, over }) => {
134-
if (!over) {
135-
return
136-
}
137-
if (active.id !== over.id) {
138-
const oldIndex = layers.findIndex((layer) => layer.id === active.id)
139-
const newIndex = layers.findIndex((layer) => layer.id === over.id)
140-
dispatch(moveLayer({ oldIndex, newIndex }))
141-
}
142-
}
133+
const handleDragEnd = useCallback(
134+
({ active, over }) => {
135+
if (!over) {
136+
return
137+
}
138+
if (active.id !== over.id) {
139+
const oldIndex = layers.findIndex((layer) => layer.id === active.id)
140+
const newIndex = layers.findIndex((layer) => layer.id === over.id)
141+
dispatch(moveLayer({ oldIndex, newIndex }))
142+
}
143+
},
144+
[dispatch, layers],
145+
)
143146

144147
return (
145148
<DndContext

0 commit comments

Comments
 (0)