Last active
October 7, 2020 06:32
-
-
Save royteusink/ecae35628d609e8a6572789877bbf1b8 to your computer and use it in GitHub Desktop.
immutable.js - Move item in List to a specific location (change sequence, reorder)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (action.toindex < 0) return state; | |
var olditem = state.get(action.index); | |
var newlist = state.delete(action.index).insert(action.toindex, olditem); | |
return newlist; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't know what i had copied wrong, but also #comment-2271960 didn't worked for me with v4 immutable.
This is what i now got, also in the need to move items in nested map/array a lot:
CodeSandbox