Forgive me, I'm a react noob. I'm trying to access the data inside a javascript/react object. The json data looks like this:
"schoolData": {
"student": [
{
"name": "blah",
"type": "lorem",
"grade": 90,
}
],
"class": null
},
What I'm trying to display is essentially just like this...
Student
name: Blah type: lorem grade: 90
Class
--- no data here ---
So I'm trying like this:
import React, { PropTypes } from 'react';
const SchoolDataPropTypes = {
SchoolData: PropTypes.object.isRequired,
};
function School(props) {
return (
<div className="section">
<h3 className="head">School Data</h3>
<div className="row">
<ul className="Uli">
{(props.data || []).map(function(value) {
return <label>{props.data.key}</label><li key={value}>{key}: {value}</li>
})}
</ul>
</div>
</div>
);
}
School.propTypes = SchoolPropTypes;
export default School;
It obviously doesn't work. So that I can render each array inside the object?