react-sortablejs icon indicating copy to clipboard operation
react-sortablejs copied to clipboard

Movement between different

Open weiblank opened this issue 2 years ago • 2 comments

When group A moves to group B, how do I determine the execution sequence of onRemove and onAdd

weiblank avatar Feb 22 '23 12:02 weiblank

+1, Multiple setlists are required, and they are difficult to work with

const list1 = useMemo((=>rawList.filtter(o=> o.age>5),   [rawList]))
const list2 = useMemo((=>rawList.filtter(o=> o.age<5),   [rawList]))

const setList1 =>(val)=> setRawList(...doSomeThing)
const setList2 => val=> setRawList(...doSomeThing)

<ReactSortable list={list1} setList={setList1} group='group'/>
<ReactSortable list={list2} setList={setList2} group='group'/>

above code is not work

vaynevayne avatar Jun 02 '23 03:06 vaynevayne

This works really well actually. You just need to compare the new list length vs the state list to see if something was removed or added. I used lodash differenceBy to get what was added and removed

makis-x avatar Aug 22 '23 17:08 makis-x