Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 947
Jens Bouma Avatar asked Oct 28 '25 17:10

Jens Bouma


2 Answers

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}} />
like image 113
Sumit Sharma Avatar answered Oct 31 '25 08:10

Sumit Sharma


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

like image 37
BenoHiT Avatar answered Oct 31 '25 08:10

BenoHiT