September 2017
Intermediate to advanced
216 pages
6h 8m
English
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?
Read now
Unlock full access