Home > other >  How to display images from a variable in react native?
How to display images from a variable in react native?

Time:09-24

I am displaying images in my react native app.

Here is how I am displaying the image:

<Image style={styles.image} source={{ uri: this.props.img }}

My image is not displayed, but when I put the url directly into the image I works fine

What is happening

CodePudding user response:

You don't have to put this in elements, please remove it before props and use directly as below

<Image style={styles.image} source={{ uri: props.img }}

CodePudding user response:

Make sure, if there is an image in your props that you've passed. console.log that prop.

Also, add this keyword only when you're using the class approach.

  • Related