SortableJS / Sortable

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
https://sortablejs.github.io/Sortable/
MIT License
29.78k stars 3.7k forks source link

How to let outside state management (Redux, Vuex) handle order and placement? #2285

Open ChristopherJohnson25 opened 1 year ago

ChristopherJohnson25 commented 1 year ago

How can I use outside state management (Redux, Vuex) handle order and placement? I need to know order and shared item, but how can I let React/Vue manipulate the dom with it's store?

mlisowsk commented 1 year ago

I suggest you handle state in Redux and ignore the SortableJS store. Just render the new items to DOM in new order when needed - make sure to not remove the root element (item container) which you passed to Sortable.create(). Update your state after user sorted using appropriate SortableJS events (e.g. onEnd).