File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments