I try to scroll always to the bottom of my flatlist in my react native app but unfortunately I don't get a reference to the flatlist.
<View style={styles.viewPointOverview}>
<Text > Point overview: </Text>
<FlatList
ref={(ref) => this.flatList = ref}
data={pointRecord}
renderItem={({ item }) => <Text>{item}</Text>}
/>
</View>
And in the render function I try to call the method scrollToEnd()
this.flatList.scrollToEnd();
I tried it in the flatlist with
ref = {"flatlist"}
or
ref = "flatlist"
But none of them have worked I always get the error: TypeError: Cannot read property 'scrollToEnd' of undefined.
You can find the complete code here: https://github.com/AlessandroVol23/Counter10000/blob/master/app/screens/PlayScreen.js