I'm making a country picker with flags. The country names and flag image name is coming from database, like this (sample):
dataSource: [
{
id: 1,
name: "Afghanistan",
image: '../assets/flags/af.png'
},
{
id: 2,
name: "Bahrain",
image: '../assets/flags/ba.png'
},
{
id: 3,
name: "Canada",
image: '../assets/flags/ca.png'
}]
Then I send that dataSource to my component
<CountryPickerFlags
dataSource={this.state.dataSource}
/>
Then in the component FlatList (renderItem) I do:
_renderItemListValues(item, index) {
var image_uri = {uri: item.image} ;
console.log(JSON.stringify(image_uri));
return (
<TouchableOpacity
activeOpacity={1}
style={styles.listRowClickTouchStyle}
onPress={() => this._setSelectedIndex(item.id, item.name)}
>
<View style={[styles.listRowContainerStyle,{ flexDirection:'row', justifyContent: 'center', alignItems: 'center'}]} >
<Image source={image_uri} />
<Text style={styles.listTextViewStyle}>{item.name}</Text>
</View>
</TouchableOpacity>
);
}
But the flag is not rendered.... If I hardcode the image (with require) it's working...
<Image source={require("../assets/flags/af.png")} />
How can I do it?