Last active
July 30, 2021 08:08
-
-
Save louicoder/7f0923d30d8e74a197c69f503cb4e919 to your computer and use it in GitHub Desktop.
Flatlist 3 colmun grid view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { View, Text } from 'react-native'; | |
| const FlatListGrid = ({ onEndReached }) => { | |
| const numColums = 3; | |
| return ( | |
| <FlatList | |
| style={{ flex: 1 }} | |
| // refreshing={loading} | |
| // onRefresh={refresh} | |
| showsVerticalScrollIndicator={false} | |
| // keyExtractor={() => Helpers.generateKey()} | |
| numColumns={3} | |
| contentContainerStyle={{ width: '100%', alignItems: 'center' }} | |
| style={{}} | |
| onEndReached={onEndReached} | |
| onEndReachedThreshold={0.01} | |
| data={state.products} | |
| renderItem={({ item, index }) => ( | |
| <View | |
| style={{ | |
| width: Math.floor(0.33 * width), | |
| // marginHorizontal: item.margin ? RFValue(1) : 0, | |
| alignItems: 'center', | |
| justifyContent: 'center', | |
| backgroundColor: '#aaa', | |
| height: Math.floor(0.33 * width), | |
| margin: Math.floor(0.01 * width) | |
| }} | |
| > | |
| <Text style={{ color: '#fff' }}>{item.index}</Text> | |
| </View> | |
| )} | |
| /> | |
| ); | |
| }; | |
| export default FlatListGrid; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment