Invalid call at line : Require with a string in database

Viewed 18

I am trying to map some SQL results and to display it in a Card. Everything is working fine but now i am trying to add a Cover in the card.

My URL IMAGE is store in a SQLite database.

Here is my code :

  let tests= Object.values(searchTests).map(function(d: any, idx){

    return (
       <Card style={styles.cardsFirst} key={idx} onPress={() => Linking.openURL(d.url)}>
        
           <Card.Content>
           <Card.Cover style={styles.image} source={require(d.url_image)} />
             <Title style={styles.title}>{d.company_name}</Title>
             <Ionicons style={styles.plus} size={20} name='arrow-redo-circle-outline'></Ionicons>
           </Card.Content>
       </Card>
   )
  })

I am having the following issue :

Invalid call at line XX : require(d.url_image)

This is working if i replace source={require(d.url_image)} by something like source={require('https://www.picsum.photos/700')}

If i log d.url_image, i have my values like '../assets/images/test1.jpg' , then '../assets/images/test2.jpg' , etc.

Thanks for help in advance :)

0 Answers
Related