If i just set require('../img/dest.png')
the image is working, but when i try to use like
It will show error
calls to require expect exactly 1 string literal argument but this was found: require(""+item.img+"").(null)
Any one knows what happens in my dollar variable ?
Thanks in advance.
render() {
// Taken from https://flatuicolors.com/
const items = [
{ name: 'Name', code: '#1abc9c', url: 'yahoo.com.tw', img: '../img/dest.png' }
];
return (
<GridView
itemDimension={130}
items={items}
style={styles.gridView}
renderItem={item => {
console.log(`'${item.img}'`);
return (
<TouchableOpacity onPress={() => this.showLinkAlert(item.name, item.url)}>
<ImageBackground source={require(`'${item.img}'`)} style={[styles.itemContainer, { backgroundColor: '#bdc3c7' }]}>
<Text style={styles.itemName}>{item.name}</Text>
</ImageBackground>
</TouchableOpacity>
);
}}
/>
);
}
}