From 9595344e8567ec894a6d448f3fd15ee319f793f2 Mon Sep 17 00:00:00 2001 From: Peter Hoppe Date: Tue, 14 Feb 2023 01:50:41 +0100 Subject: [PATCH] reorder --- src/components/DndList.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/DndList.tsx b/src/components/DndList.tsx index 006d850..6048b9e 100644 --- a/src/components/DndList.tsx +++ b/src/components/DndList.tsx @@ -48,6 +48,18 @@ export interface DndListProps { dataprops: DndListProps; } + const reorder = ({ from, to }: { from: number; to: number }) + { + const cloned = [...current]; + const item = current[from]; + + cloned.splice(from, 1); + cloned.splice(to, 0, item); + + return cloned; + }; + + export function DndList({dragEndHandler, dataprops}: IProps) { const {data} = dataprops;