I am unable to access the value from a object key.
componentDidUpdate(prevProps) {
if (prevProps !== this.props) {
console.log("component did update in top menu", this.props.topmenudata[0])
this.setState({
});
}
}
In the above method i have passed some data to my child component through props and it is accessed through .topmenudata
when i console.log(this.props.topmenudata[0]), i get the following object
{baudrate: "1200", databits: "7", parity: "even", stopbits: "1"}
when i console.log(this.props.topmenudata), i get the following object
0: {baudrate: "1200", databits: "7", parity: "even", stopbits: "1"}
length: 1
__proto__: Array(0)
yet, when i try to get the value of baudrate from the object, through
console.log(this.props.topmenudata[0]["baudrate"])
i get the following returned
Cannot read property 'baudrate' of undefined
i have checked the type of data i am getting through
typeof(this.props.topmenudata[0])
and it shows that i am definitely getting an object
what am i missing here? is there something im missing in the componentdidupdate method?