Skip to content

Instantly share code, notes, and snippets.

@Darmikon
Last active January 29, 2017 15:08
Show Gist options
  • Save Darmikon/248dea24d2c7b166b17088eb91640e66 to your computer and use it in GitHub Desktop.
Save Darmikon/248dea24d2c7b166b17088eb91640e66 to your computer and use it in GitHub Desktop.
How to update deep nested structures in redux without headache with https://github.com/kolodny/immutability-helper
var src = {
obj: {
nestedArr: [
{
string: 'str_before'
}
]
},
arr: [
{
num: 2
}
]
}
console.log(update(src,{
arr: {
0: {
num: {
$set: src.arr[0].num + 666
}
}
},
obj: {
nestedArr: {
0: {
string: {
$set: src.obj.nestedArr[0].string + '_after'
}
}
}
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment