Reputation: 380
I would like to show the image from the File path example from c:/foldername/x.png. When I have given file path, we are getting cross mark but it is not loading the image, anyone has any idea? Code which I was working
<Image source={require('C:/Users/username/Pictures/66.png')}
style={{
width:220,
height:220,
borderWidth:2,
borderColor:'#d35647',
resizeMode:'stretch',
margin:8
}}
/>
Upvotes: 0
Views: 862
Reputation: 316
If you have for example, the follow scafolding
src
|____/assets
|_________imgs
|_____________mi-img.png
|____/components
|_________/MyImage
|_____________MyComponent.js
in MyComponent.js
you must access to your image in the follow way:
<Image source={require('../../assets/imgs/mi-img.png')}
style={{
width:220,
height:220,
borderWidth:2,
borderColor:'#d35647',
resizeMode:'stretch',
margin:8
}}
/>
Upvotes: 0