Savad
Savad

Reputation: 1306

How do I render image component based on the image uri inside an array in React Native?

I have an array of image URI.

["file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22536474236950.png","file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22583225016770.png"]

I want to render the image component based on the length of the array and show and show all the images. How can I do it in react native

Upvotes: 0

Views: 430

Answers (2)

lovepreet singh
lovepreet singh

Reputation: 118

If you have image in array you can use map function and display in image component

data = ['a.png',b.png']

data.map((item,index)=>{<Image src={item.data })

like that it is just demo example

Upvotes: 0

Tanveerbyn
Tanveerbyn

Reputation: 784

I believe this will help you:

var array =   ["file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22536474236950.png","file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22583225016770.png"]
    
   array.map((x)=>{
     return(<Image source={x || whatever you want } style={{xx:"xx"}} />)
   })

Upvotes: 1

Related Questions