Immutable.js Push into array in nested object

痞子三分冷 提交于 2019-12-04 22:40:26
zerkms

This should work

initialState.updateIn(['foo', 'bar'], arr => arr.push(4))

References:

I'm using seamless-immutable, when I'm adding a new item to array of nested object, I got this error:

The push method cannot be invoked on an Immutable data structure.

My array still has push method, but it doesn't work. The solution is use concat instead, more details on #43:

initialState.updateIn(['foo', 'bar'], arr => arr.concat([4]));

Hope this help!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!