I'm working with React 16 and my goal I'm trying to render an array from a JSON file, I'll appreciate any help.
JSON: trying to render a list of codigoLote
{
"_id" : "bMv7ip59zuy3PyTvD",
"codigo" : "001",
"name" : "Nombre 1",
"lab" : "Lab 2",
"principio" : "activo",
"dosis" : "dos",
"sintomas" : "tres",
"contra" : "cuatro",
"createdAt" : ISODate("2017-11-05T19:12:19.628Z"),
"Lotes" : [
{ "codigoLote" :"B4578", "cantidad" : "100", "costo" : "0.00",
"fIngreso" : "7/11/2017", "fVence" : "7/11/2017" }
{ "codigoLote" :"B4579", "cantidad" : "100", "costo" : "0.00",
"fIngreso" : "7/11/2017", "fVence" : "7/11/2017"}
] }
I tried this but React won't render it with this error: Uncaught Error: Objects are not valid as a React child (found: object with keys {codigoLote, cantidad, costo, fIngreso, fVence}). If you meant to render a collection of children, use an array instead.
<Row>
{this.props.meds.Lotes}
</Row>
I tried this solution as well, but it doesn't seem to find my the fields on the array.
var ListRender = React.createClass({
render: function() {
return (
<ul>
{this.props.meds.Lotes.codigoLote(function(listValue){
return <li>{listValue}</li>;
})}
</ul>
)
}
});
. . .
<Row>
<ListRender />
</Row>