Value of uri cannot be cast from double to string

1.7k Views Asked by At

im working with Yelp Api and i tried to search for Restaurants but im having a problem with the Restaurant image im getting the name and rating with no problem but for the image its showing for the first time but when i reload my app it give this error : Value of uri cannot be cast from double to string

here's the code :

const RestaurantItems=(props)=>{
    return(
        
        <ScrollView>
    <View style={props.theme=='light'?styles.container:styles.darkContainer}>
        
        {props.restaurantsData.map((item,index)=>(
        
            <View style={{marginTop:20}} key={index}>
                 <View style={styles.Img}>
              <Image source={{uri:item.image_url}}style={{width:'100%',height:180}} />
              

        </View>
        <View style={{paddingLeft:10,marginTop:15,flexDirection:"row",justifyContent:'space-between',alignItems:"center"}}>
            <View>
              <Text style={[{fontSize:19,fontWeight:"700"},props.theme=='dark'?{color:'white'}:{color:'black'}]}>{item.name}</Text>
              <Text style={{color:'#717171'}}>35-45 m</Text>
              </View>
              <View style={{marginRight:10,backgroundColor:"#eee",paddingHorizontal:7,borderRadius:30}}>
                  <Text style={{fontSize:19,fontWeight:"500"}}>{item.rating}</Text>
              </View>
        </View>
            </View>
        ))}
        </View>
        </ScrollView>
       

       
    )}```
1

There are 1 best solutions below

3
Dheeraj On

item.image should be url string check the value of props.restaurantsData may be one of the index has image_url as number OR try replacing item.image with item.image_url.toString()