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

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?

主站蜘蛛池模板: 防城港市| 随州市| 辽宁省| 固始县| 汾阳市| 易门县| 建湖县| 南充市| 安乡县| 隆子县| 德令哈市| 西林县| 辛集市| 稻城县| 富平县| 乐安县| 黔东| 临朐县| 宁强县| 罗源县| 衡阳县| 福海县| 滦南县| 衡水市| 宿松县| 蒙城县| 贵溪市| 莱州市| 三门县| 河北区| 广河县| 芒康县| 涿州市| 图们市| 堆龙德庆县| 沅江市| 禄丰县| 扶余县| 津南区| 霍城县| 漠河县|