How to print an object on page?
As a function component with JSON.stringify additional arguments for indentation
import React from 'react';
var person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
const StringifyObject = () => (
<pre>
{JSON.stringify(person, null, 2)}
</pre>
)
I think your example should work. Not sure what kind of representation you are hoping for but I put an example on jsfiddle where I use JSON.stringify to print out an object.
https://jsfiddle.net/5yq9fev6/1/
var world = {
'abc' : [1, 2, 3],
'b': {
1: 'c'
}
}
var Hello = React.createClass({
render: function() {
return (
<div>
<div>{JSON.stringify(world)}</div>
</div>
)
}
});
React.render(<Hello />, document.getElementById('container'));