简体   繁体   English

ImmutableJs:更新嵌套Map中的列表

[英]ImmutableJs : Updating a List in nested Map

I have a hard reading the ImmutableJS and other questions answers... It seems simple, I have a Map like this : 我很难阅读ImmutableJS和其他问题的答案...似乎很简单,我有一个像这样的Map:

{
  foo: [
    {id: 1, name: 'John'}, 
    {id: 2, name: 'Christine'}, 
    {id: 3, name: 'Frank'}, 
    {id: 4, name: 'Jenny'},
  ]
}

How can i update change "John" to "Johnny" ? 如何将“ John”更改为“ Johnny”?

From the docs you can use this: 文档中,您可以使用以下代码:

newMap = oldMap.setIn(['foo', 0, 'name'], 'Johnny');

You pass an array of keys, then the value. 您传递键数组,然后传递值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM