I want to create horizontal flatlist with multiple rows in my app, but the output is just one row, how to make this to be multiple rows?
I've tried to make this.state.products to array and splice it with 3 size each array, but it didn't change.
constructor() {
super();
this.state = {
products = products
}
}
render() {
var arrays = [], size = 3;
while(this.state.products.length > 0)
arrays.push(this.state.products.splice(0, size)
return(
<FlatList
horizontal={true}
data={arrays}
keyExtractor={(item, index) => index.toString()}
renderItem={({item, index}) => (
<Text>{item[0].name}</Text>
<Text>{item[0].description}</Text>
{item.length > 1 ?
<Text>{item[1].name}</Text>
<Text>{item[1].description}</Text>
: null}
{item.length > 2 ?
<Text>{item[2].name}</Text>
<Text>{item[2].description}</Text>
: null}
)}
/>
)
}
I want in first column has 3 rows with different data of products in each row. And if it has 3 rows it will be move to next column with 3 rows again.