Skip to main content

Imutable Splice Order In Drag

Use react-dnd to drag and realize imutable splice with typescript.

––– views

react-dnd

Official Case

Starting with the official example provided above, immutability-helper has been used with its update function. It performs the task of sorting items in an array upon dragging and dropping an item.

Typescript Case

Another ergonomic solution to consider would be immer. immer allows you to deal with immutable state in a more direct way with the produce function. Like the previous method, it enables drag-and-drop operations while still ensuring immutability.

Immer Case

Another ergonomic solution to consider would be immer. immer allows you to deal with immutable state in a more direct way with the produce function. Like the previous method, it enables drag-and-drop operations while still ensuring immutability.

Conclusion

While immutability-helper is a useful tool for handling immutable data, both lodash and immer suggest simpler and more straightforward alternatives, especially with TypeScript. It's important to remember that using such libraries to maintain immutability can simplify debugging and enhance your React application's performance.