How do I grab value from nested immutable Map Object? Please Answer

226 views Asked by At

I am trying to grab data from an array of objects called "nodes". I've console logged:

console.log(props.mapValues.get('entries'))

to grab the object but it returns an array length of 0.

This is what I console.log when printing the map. I've shortened this version:

size: 4
__altered: false
__hash: undefined
__ID: undefined
_root: ArrayMapNode
    entries: Array(1)
        0: Array(2)
            0:"default"
          1: Map
            size:10
            __altered: false
            --hash:undefined
            _root:BitmapIndexedNode
              bitmap:
             nodes: Array(4)
               0: Value{}
               1:Value{}
               2:Value{}
               3:BitmapIndexNode{}
               [[Prototype]]Array(0)
     

Here is a screenshot of the object. I want to access "nodes" so I can get the values in the array. enter image description here

How can I access data?

1

There are 1 answers

0
dube On

There is a Chrome Extension to pretty-print immutable.js objects, which might help you.

You can always use the toJS to deeply convert things back to plain old objects (and toJSON for a shallow conversion).

Reminder: calling toJS for debugging is convenient. However, try to avoid it in productive code as it is bad for performance, especially when called repeatedly in the render() loop.