Last active
October 26, 2021 09:21
-
-
Save hgale/672f5a3b1782ffecb14e3f5a246de9ca to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
Platform, | |
StyleSheet, | |
Text, | |
View, | |
FlatList, | |
Dimensions, | |
ScrollView, | |
} from 'react-native'; | |
const pageNumbers = [1, 2, 3]; | |
const imageIds = ['A', 'B', 'C']; | |
type Props = {}; | |
export default class App extends Component<{}> { | |
render() { | |
return ( | |
<FlatList | |
data={pageNumbers} | |
initialNumToRender={3} | |
horizontal={true} | |
getItemLayout={(data, index) => ( | |
{length: 200, offset: 200 * index, index} | |
)} | |
keyExtractor={pageNumber => pageNumber.toString()} | |
renderItem={({ item: pageNumber }) => ( | |
<View style={styles.page}> | |
<Text>{`page ${pageNumber}`}</Text> | |
<FlatList | |
data={imageIds} | |
getItemLayout={(data, index) => ( | |
{length: 200, offset: 200 * index, index} | |
)} | |
initialNumToRender={3} | |
horizontal={true} | |
extraData={'asdasd'} | |
keyExtractor={imageId => imageId} | |
renderItem={({ item: imageId}) => ( | |
<View style={styles.pageStyleOne}> | |
<Text>{`image ${imageId}`}</Text> | |
</View> | |
)} | |
/> | |
</View> | |
)} | |
/> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
page: { | |
width: Dimensions.get('window').width, | |
borderWidth: 2, | |
borderColor: 'blue', | |
marginTop: 20, | |
alignItems: 'center', | |
}, | |
pageStyleOne: { | |
width: Dimensions.get('window').width, | |
borderWidth: 2, | |
height: 200, | |
borderColor: 'red', | |
marginTop: 20, | |
alignItems: 'center', | |
}, | |
pageStyleTwo: { | |
width: Dimensions.get('window').width, | |
borderWidth: 2, | |
height: 200, | |
borderColor: 'yellow', | |
marginTop: 20, | |
alignItems: 'center', | |
}, | |
pageStyleThree: { | |
width: Dimensions.get('window').width, | |
borderWidth: 2, | |
height: 200, | |
borderColor: 'purple', | |
marginTop: 20, | |
alignItems: 'center', | |
}, | |
image: { | |
width: Dimensions.get('window').width, | |
height: 200, | |
borderWidth: 2, | |
borderColor: 'green', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it working fine, because I have tried the same, and the nested one is displaying in vertical order.