I'm searching a way to make an horizontal ListView or FlatList In React-native.
like the image below:
I tried to managed it with Flex but it's make me stranges results, and always with a vertical ListView
If you got any idea, let me know.
Regards,
To add a horizontal FlatList in React Native, we just set the horizontal prop of the FlatList to true . to add horizontal to FlatList . As a result, we can scroll through the FlatList items horizontally.
The FlatList component has a prop named as horizontal={} which support Boolean value True and False. The default value is False and if we define its value to True then it will make our FlatList horizontal with horizontal scrolling enabled.
FlatList - More performant compared to ListView. ListView rendering can get slow once the number of items grows larger. FlatList significantly improves memory usage and efficiency (especially for large or complex lists) while also significantly simplifying the props — no more dataSource necessary!
The answer is to add the horizontal property set to true
.
Yeah now it's described in the doc: https://reactnative.dev/docs/flatlist#horizontal
So obviously a FlatList is a Child of a ScrollView so he got the Horizontal Bool.
<FlatList horizontal={true} data={DATA} renderItem={renderItem} keyExtractor={(item) => item.id} extraData={selectedId} />
Ciao
Thanks for the last answer, ListView is now deprecated.
solution with FlatList:
<FlatList style={styles.videos_flatList} horizontal={true} data={data1} renderItem={({item}) => <RowItem/> } ItemSeparatorComponent={() => { return ( <View style={{ height: "100%", width: 20, backgroundColor: "#CED0CE", }} /> ); }} keyExtractor={(item, index) => index.toString()} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With