Sarah Sarah - 2 months ago 22
React JSX Question

ReactJS getting value from a map data structure

When I'm trying to print the value of a prop in the

Reactjs
code, I'm getting the following:

console.log(this.props.rec.get('data'));

Map
__altered: false
__hash: undefined
__ownerID: undefined
_root: ArrayMapNode
entries: Array[8]
0: Array[2]
1: Array[2]
2: Array[2]
3: Array[2]
0: "language"
1: "ena"
4: Array[2]
5: Array[2]
0: "owners"
1: List
length: 2
__proto__: Array[0]
6: Array[2]
7: Array[2]

length: 8
__proto__: Array[0]
ownerID: OwnerID
__proto__: Object
size: 8
__proto__: KeyedIterable


entries
is a function. How can I get the value of "language" and "owners" from this data?

I don't really understand this structure, can someone please explain it to me?

Answer

Did you know that it seems that you are using immutable.js? Check its docs https://facebook.github.io/immutable-js/docs/#/Map

Try:

console.log(this.props.rec.get('data').get('language'))
console.log(this.props.rec.get('data').get('owners').get(0))
Comments