React native flatlist initial scroll to bottom

I had similar issue. If you want to have you chat messages start at the bottom, you could set “inverted” to true and display your messages and time tag in an opposite direction.

Check here for “inverted” property for FlatList. https://facebook.github.io/react-native/docs/flatlist#inverted

If you want to have you chat messages start at the top, which is what I am trying to achieve. I could not find a solution in FlatList, because as you said, the heights are different, I could not use getItemLayout which make “scrollToEnd” behave in a strange way.

I follow the approach that @My Mai mentioned, using ScrollView instead and do scrollToEnd({animated: false}) in a setTimeout function. Besides, I added a state to hide the content until scrollToEnd is done, so user would not be seeing any scrolling.

Leave a Comment

tech