Slakk
Slakk

Reputation: 127

Pass down immutable list to a componenet requiring an Array

I'm new to react and from what I've been reading it's not advised to use .toJS() from as it will affect performance.

But I'm using a third party component that requires an array as props but my state is set as an immutable list.

In this particular case should I use .toJS on my immutable list or do there is another way that wouldn't affect performance ?

Thanks

Upvotes: 2

Views: 1345

Answers (1)

kudlajz
kudlajz

Reputation: 1066

Immutable collections have toArray method, which will convert any Immutable structure to array. Keep in mind, this operation converts to array only shallowly.

Upvotes: 1

Related Questions