How to access value in immutable object/map in JS?

398 Views Asked by At

I am trying to grab the 'message' value but it is returning undefined when I use this:

console.log('message: ', props.information.getIn(['_root', 'entries']))

To console log the data below I use this "console.log(props.information)"

size: 4
__altered: false
__hash: undefined
__ownerID: undefined
_root: ArrayMapNode
    entries: Array(4)
        0: (2) ['Name', 'Update']
        1: (2) ['title', 'Update']
        2: (2) ['message', 'Click here to learn about......']
        3: (2) ['clickURL', 'www.google.com']
length: 4
[[Prototype]]: Array(0)

I've checked another similar post but I am not understanding. Getting value from a map data structure This question is most similar, but I've tried what they did: 'props.information.get('_root').get('entries')' doesn't work for me

2

There are 2 best solutions below

8
Max Filippov On

What you need to do is this:

console.log('message: ', props.information.getIn(['entries']));
1
Colorful Codes On

So this is what ended up working for me

props.Information.get('message')