简体   繁体   中英

ImmutableJS how to get a value inside an object?

I have this Immutable Map and I need to get to the property name : 在此处输入图片说明

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 ?

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'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM