Reputation: 3436
I'm trying to modify a list with Immutable.js. AFAIK, the syntax should be
import {List} from './immutable'
let origList = List(['a', 'b', 'c'])
let newList = origList.push('d')
// newList is coming out equal to 4
newList is taking an integer value: the size of the list; Immutable.js objects should return a modified version when you use them. How can I make a modified version of the list, ie using it in a Redux reducer?
Per the offical docs: "push() returns a new List with the provided values appended, starting at this List's size."
Upvotes: 0
Views: 44
Reputation: 9822
ImmutableJS actually works as it should and returns a new, updated list. See snippet below.
let origList = Immutable.List(['a','b','c']);
console.log(origList.push('d'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.1/immutable.min.js"></script>
Upvotes: 1