官术网_书友最值得收藏!

Setting list values

When you set list values using the set() method, you're changing an existing value. More specifically, you're overwriting the current value at a given index with a new value:

const myList = List.of(1);
const myChangedList = myList.set(0, 2);

console.log('myList', myList.toJS());
// -> myList [ 1 ]
console.log('myChangedList', myChangedList.toJS());
// -> myChangedList [ 2 ]

You're updating the first list value—because the index you're passing to set() is 0—with a value of 2. Using set() like this is a good choice when you know ahead of time what the new value should be. But what about when the new value depends on the current value?

主站蜘蛛池模板: 油尖旺区| 家居| 永福县| 宣城市| 澄江县| 和田县| 邵东县| 长垣县| 西青区| 读书| 玛沁县| 新竹市| 嘉善县| 阳东县| 禄劝| 大洼县| 永安市| 亚东县| 来宾市| 开平市| 南丹县| 永清县| 册亨县| 郑州市| 罗源县| 遂宁市| 突泉县| 通化县| 鄂尔多斯市| 福清市| 天长市| 丰原市| 兰坪| 绥中县| 凤庆县| 黑河市| 文昌市| 临江市| 黄石市| 曲周县| 涞水县|