OK, so Im getting this error when trying to return some data from my web api. Ive tried all as suggested on other similar posts but cant get this working. Any help appreciated.
Objects are not valid as a React child (found: object with keys {addressType, address1, address2, city, county, postCode, country, id}). If you meant to render a collection of children, use an array instead.
data...
"rows": [
{
"company": null,
"controlPanel": null,
"name": "Basement",
"cloudAccessEnabled": true,
"notes": "quad volcans quad quo si imaginator volcans brevens, nomen gravum Multum plorum brevens, in e quo quad",
"addresses": [
{
"addressType": "HeadOffice, Marketing",
"address1": "729 Rocky First Blvd.",
"address2": "APT 22",
"city": "Haverhill",
"county": "Dunbartonshire",
"postCode": "SL1 9GH",
"country": null,
"id": "62a494ee-37cf-3021-5a29-00b54adc9255"
}
],
"installers": null,
"lastMaintenance": "2016-06-30T00:00:00",
"nextMaintenance": "0001-01-01T00:00:00",
"latestResult": "None Yet",
"id": "c0d44330-8369-0e78-f45b-000142b59fa8"
},
how I am trying to display in datatable... https://github.com/jbetancur/react-data-table-component
//this works
//cell: row => <div>{row.notes}</div>,
//doesnt work-Objects are not valid as a React child error
cell: row => (
<div>
{row.addresses.map((addressType, id) => (
<div key={id}>{addressType}</div>
))}
</div>
),
adressTypeyou are passing in your map function is not what you think you are passing, that adressType is actually youraddresses[i]for that iteration so what you should do is:<div key={adressType.id}>{adressType.adressType}</div>. Change theadressTypein map function to a better name likeaddressthen doaddress.idandadress.adressTypeand remove theidfrom your map function.