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

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?

主站蜘蛛池模板: 黎平县| SHOW| 安阳市| 逊克县| 合水县| 类乌齐县| 龙岩市| 哈密市| 兴山县| 永吉县| 仪陇县| 乌兰浩特市| 陕西省| 衢州市| 蒲城县| 南开区| 泸州市| 博野县| 肇东市| 泗水县| 桃园市| 正镶白旗| 新宁县| 云梦县| 西平县| 澳门| 繁昌县| 桐城市| 石门县| 疏勒县| 二手房| 黑河市| 宁晋县| 三都| 绍兴县| 鹤岗市| 读书| 忻城县| 汾阳市| 曲麻莱县| 界首市|