Evan Sebastian
Evan Sebastian

Reputation: 1744

Avoid ImmutableJS Map converting arrays to List

Curently if I have m.set(someArray) where m is a Map, it will try to convert someArray to Immutable List. How do I disable this behaviour?

Upvotes: 0

Views: 55

Answers (1)

Cerbrus
Cerbrus

Reputation: 72857

Pass a copy of the array, instead:

m.set(someArray.slice());

Note that, if the array contains reference values (objects, arrays), the references are copied. .slice() is only a shallow copy.

Upvotes: 2

Related Questions