I'm trying to get the image string from the mock data array and push it inside <Image>
Component in React Native. Here's my Data array:
const data= [
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item01.jpg',
},
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item02.jpg',
},
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item03.jpg',
},
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item04.jpg',
},
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item05.jpg',
},
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item06.jpg',
},
{
title: 'Lorem ipsum dolor sit amet.',
price: '$1.99',
image: '../assets/img/item07.jpg',
},
];
I'm trying to use the image value via mapping the data array. The Image Component is:
<View style={{
width: 164,
height: 164,
borderRadius: (1 / 2) * 164,
backgroundColor: color.white,
shadowColor: 'rgba(57,57,57,0.5)',
shadowOffset: { width: 0, height: 1 },
shadowRadius: 2,
elevation: 20,
overflow: 'hidden',
}}>
<Image
source={require(data.image)}
resizeMode='contain'
style={{ width: null, height: null, flex: 1 }}
/>
</View>
if I use this, then there's an error occurred:
Invalid call at line 60: require(item.illustration)
If I use-
source={{ uri: item.illustration }}
instead of require function, then Nothing appears.
Can anyone help me out with how Can I import Local Image from an array?