i have object something like this
export const contact =
{
_id: "1",
first:"John",
name: {
first:"John",
last:"Doe"
},
phone:"555",
email:"[email protected]"
};
i am reading it like
return (
<div>
<h1>List of Contact</h1>
<h1>{this.props.contact._id}</h1>
</div>
)
in this scenario i am getting expected output.
return (
<div>
<h1>List of Contact</h1>
<h1>{this.props.contact.name.first}</h1>
</div>)
when i read the nested property i am getting error like Uncaught TypeError: Cannot read property 'first' of undefined
how to read these king of nested objects in react
https://github.com/bhavankris/testing1/blob/master/src/pages/contact-list-page.js
please find the github repo
contact
is the variable but you code usescontacts
. – The Head Rush 57 mins ago