Reputation: 4746
First I tried to load image with following code and it does load the image
render(){
return(
<View style={{backgroundColor:'red', flex:1, alignItems:'center'}}>
<Text> Landing Page controller</Text>
<Image
source={require('./symbol.png')}
/>
</View>
); }
Now i have load lots of image through out the application from different files. In such case it is very difficult to maintain the code and resources. That's why I created the separate file
resource.js
module.export= {
symbol:require('./symbol.png'),
};
and then in component file I tried to load like below.
import JResource from './resource.js';
.....................
..................
render(){
return(
<View style={{backgroundColor:'red', flex:1, alignItems:'center'}}>
<Text> Landing Page controller</Text>
<Image
source={JResource.symbol}
/>
</View>
);
}
Now the application did run , but no image is displayed. It would be great if any body would figure out what's wrong here.
Upvotes: 3
Views: 1299