I'm using the code below, but it's not rendering anything, even testing with text or another tag, it doesn't render, but the array I'm getting I can give console.log to it and it's perfect
<View>
{
imageArray.map((array, index) => {
<TouchableOpacity key={index}>
<Image
source={{ uri: array }}
style={{ width: 150, height: 150 }}
/>
</TouchableOpacity >
})
}
</View>
CodePudding user response:
In your code you are not returning any values while going through the array.
<View>
{
imageArray.map((array, index) => {
return <TouchableOpacity key={index}> <----- Return statement
<Image
source={{ uri: array }}
style={{ width: 150, height: 150 }}
/>
</TouchableOpacity >
})
}
</View>
There are others ways in which you can accomplish what you are trying to do, but without too much rewrite of your code, a simple return statement while iterating the array should do.
CodePudding user response:
or
<View>
{
imageArray.map((array, index) =>
<TouchableOpacity key={index}>
<Image
source={{ uri: array }}
style={{ width: 150, height: 150 }}
/>
</TouchableOpacity >
)
}
</View>