'showing the error when connecting the api to react native
I want to connect react native project to an api. but it showing the error
ERROR TypeError: undefined is not an object (evaluating 'props.restaurantData.map')
export default function RestaurantItems(props) {
return (
<>
<TouchableOpacity activeOpacity={0.5} style={{ marginBottom: 30 }}>
{props.restaurantData.map((restaurant, index) => (
<View key={index} style={{
marginTop: 10,
padding: 15,
backgroundColor: 'white'
}}>
<RestaurantImage image={restaurant.image_url} />
<RestaurantInfo
name={restaurant.name}
rating={restaurant.rating} />
</View>
))}
</TouchableOpacity>
</>
)
}
Solution 1:[1]
console and check props.restaurantData.map
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vismaya Haridas |
