How to update element inside List with ImmutableJS?

后端 未结 7 1176
面向向阳花
面向向阳花 2020-12-04 09:02

Here is what official docs said

updateIn(keyPath: Array, updater: (value: any) => any): List
updateIn(keyPath: Array, notSe         


        
7条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 09:21

    You can use map:

    list = list.map((item) => { 
        return item.get("name") === "third" ? item.set("count", 4) : item; 
    });
    

    But this will iterate over the entire collection.

提交回复
热议问题