showing the error when connecting the api to react native

52 views Asked by At

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>
        </>

    )
}   
1

There are 1 answers

0
Vismaya Haridas On

console and check props.restaurantData.map