I am looking to create a Horizontal Scrolling Flatlist with 2 rows and 3 columns visible, pulling dynamic data from an API. Currently, I have successfully implemented a vertical scrolling Flatlist that resembles the following:
https://i.sstatic.net/oJJyA.png.
There is a parameter called numOfColumns
to set the number of columns, but nothing for rows. Upon attempting to set horizontal={true}
, the layout became distorted:
https://i.sstatic.net/14VwP.png
Additionally, it throws an error indicating that numOfColumns
cannot be used with a Horizontal Scrolling Flatlist. Please refer to the attached screenshot for the Desired output: https://i.sstatic.net/X3IMP.png.
This is my code for the Vertical Scrolling Flatlist:
<FlatList
ref={(ref) => { this.flatListRef = ref; }}
style={{ width: '90%', marginTop: 10, marginLeft: 10, backgroundColor: 'transparent', borderRadius: 5, alignSelf: 'center' }}
bounces={false}
// horizontal={true}
numColumns={3}
data={this.state.categoryData}
renderItem={({ item: data, index }) => {
return (
<ServiceView viewWidth={'100%'} viewHeight={'100%'} viewPaddingLeft={1} viewPaddingRight={10} viewPaddingTop={1} viewPaddingBottom={12} serviceName={(globalUserType == 'provider') ? data.services.name : data.name} serviceIconUrl={(globalUserType == 'provider') ? data.services.image : data.image} jobCount={(globalUserType == 'provider') ? '' : ''} showDot={(globalUserType == 'provider') ? false : false}
serviceAction={
() => this.navigateTo('category', data)
}/>
What modifications should be made to achieve the desired outcome.