13

I want to be able to look at my immutable objects for debugging. I find it very difficult to look through an object by clicking on entries and such. Ideally what I would like is the opposite of the formJS function

so,

const immutableObj = fromJS({name: 'bob'})
return oppositeJS(immutableObj)  
=> {name: 'bob'}
DrivingInsanee
  • 1,631
  • 2
  • 13
  • 22

2 Answers2

24

nevermind, I found it in the documentation

toJS()
Vamshi
  • 9,194
  • 4
  • 38
  • 54
DrivingInsanee
  • 1,631
  • 2
  • 13
  • 22
  • 2
    As a side note, I had the same issue debugging Immutable.js data structures and created this little helper for Chrome https://github.com/danielepolencic/immutablejs-devtools – danielepolencic Feb 11 '16 at 12:25
  • 1
    Btw, their is also `toJSON` in immutable, it's pretty much just an alias but if you wanted to be explicit about the type your expecting (namely JSON) I would use that. – Todd Moore Feb 14 '16 at 20:23
2

Just use toJS() To read more about https://devdocs.io/immutable/index#map.tojs

const immutableObj = fromJS({name: 'bob'})

const backToObj = immutableObj.toJS();
Armando Júnior
  • 138
  • 2
  • 9