Lizz Parody
Lizz Parody

Reputation: 1765

ImmutableJS how to get a value inside an object?

I have this Immutable Map and I need to get to the property name: enter image description here

If I do retrospective.get('users') I can get inside the users, but if I do retrospective.getIn(['users', 'name']) It doesn't work... how can I access to the property name?

Upvotes: 1

Views: 821

Answers (1)

fl9
fl9

Reputation: 434

It does not work because users is an array. So you have to provide an index like this

retrospective.getIn(['users', 0, 'name'])

Update:

To get all names

retrospective.get('users').map(user => user.get('name'))

Upvotes: 4

Related Questions