Reputation: 2627
I created a react native component and package it for npm following:
After this I created a new react native app and installed my new component using npm pack and npm i ...
However, every time I use Image from within this component using
const myImg = require(imagesFolder + 'Happy.jpg')
const caller = this.props.caller;
return(
<View style={{height: '100%', alignItems: 'center', backgroundColor: '#ffc600'}}>
<Text></Text>
<Image source={myImg}
style={{width:150, height:150, borderWidth: 1, borderColor: 'red', resizeMode: 'contain'}}
/>
<Text></Text>
I can not see the image and the compiler does not report that it could not find the image. Any ideas? Is there a special location for image files that need to placed at?
Thanks
Upvotes: 0
Views: 133
Reputation: 209
<Image
style={styles.tinyLogo}
source={require('@expo/snack-static/react-native-logo.png')}
For more infoenter link description here
Upvotes: 1
Reputation: 290
Try it
<Image
source={myImg}
style={{ height: 350, width: WIDTH }}
resizeMethod="resize"
resizeMode="contain"
/>
Upvotes: 1