I am receiving an unknown amount of data(images) from an API endpoint and I want to use flexbox to display the images in 2 rows and an unknown amount of columns depending on the amount of data. How is it done?
const [artistes, setArtiste] = useState(null);
//get request to endpoint
fetch('http://localhost:8000/museb/artist/',{
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
}})
.then(response => response.json())
.then(jsonResponse =>
setArtiste(jsonResponse)
)
.catch(error => console.log(error))
.finally(setLoading(false));
}, [])
This is where I'm rendering the data
<View style={{flexDirection: "row"}}>
{artistes.map((artiste, index) => (
<TouchableOpacity key={index} onPress={() => navigation.navigate("Musicplayer")} style={styles.musiccontentsmall}>
<Image source={{uri: "http://localhost:8000"+artiste.image}} style={styles.smallimage}/>
</TouchableOpacity>))}
</View>
)}
"flexDireciton: row" will put all the content in a single row, but I want it to be in two rows