(array: T[], activeId: string, overId: string)
| 35 | if (overId == null || activeId == null) return |
| 36 | |
| 37 | function getNewArray(array: T[], activeId: string, overId: string) { |
| 38 | const oldIndex = array.findIndex(section => section.id === activeId) |
| 39 | const newIndex = array.findIndex(section => section.id === overId) |
| 40 | return arrayMove(array, oldIndex, newIndex) |
| 41 | } |
| 42 | |
| 43 | startTransition(async () => { |
| 44 | setOptimisticItems(items => getNewArray(items, activeId, overId)) |