I have a React native project
I want to display manufacture’s name (brand name) above the product name like below
<View style={styles.infromationView}>
<Text>{data.manufacturers.name}</Text>
<Text>{data.product_description.name}</Text>
</View>
While adding the name, I am getting error as Cannot read property ‘name’ of undefined while getting the manufacturer / brand name table, But I am able to get the same product name from product_description table
Please check below for db structure…
Above table data is working as expected..
But, when I try to get the data from this table, I am getting error
2
Answers
try this
for more info: Optional_chaining
In this, you might be missing values, that’s why it’s showing error!
You can avoid this error by
But i think here is the issue is with your API response. I think API response data has no property name "manufacturers".
Please confirm it by
console.log({data})
.