Jens Bouma
Jens Bouma

Reputation: 149

React Native image from uri not showing

I'm working on a mobile app, but when I try to acces my images from a specific uri it won't show them. But it only shows on the computer of my friend and I did the same.

enter image description here

Above the text inside the 3 blocks there should be a image, but I receive an error.

The code:

<Image
   style={styles.image}
   source={{uri: 'http://10.0.2.2:8000/images/illustrations/' + illustration}}
   onError={(error) => console.error(error)}
/>

I don't know what is going wrong ...

Upvotes: 4

Views: 8410

Answers (3)

BenoHiT
BenoHiT

Reputation: 312

I tried pretty much everything until I put width and height, and was like a miracle

Upvotes: 1

Rahul Raj
Rahul Raj

Reputation: 516

Maybe try to restart your metro bundle.

<Image source={{ uri: `http://10.0.2.2:8000/images/illustrations/${illustration}`}} style={{ height: 80, width: 80}}

Upvotes: 0

Sumit Sharma
Sumit Sharma

Reputation: 212

You have to must give width for images in react-native. also check the path of image if the path is right just clear your metro bundler cache and restart it.

<Image source={{ uri: 'http://10.0.2.2:8000/images/illustrations' + illustration }} style={{ height: 80, width: 80}} />

Upvotes: 5

Related Questions