0

Hello guys I am creating a chat app using React Native. And in chat screen which is the core feature obviously as you know we have to scroll towards the top to load more messages. I am using Scroll View to show messages. Is there any way that I can check if the Scroll View has reached its top ( not bottom )? Thanks!

Manbir Judge
  • 113
  • 1
  • 13

2 Answers2

1

If you have a chat app that has an unknown amount of chats you should be using a flatlist in order to display them. It will save you a lot of memory. Flat list also has this functionality built in take a look at onRefresh: https://reactnative.dev/docs/flatlist#onrefresh

Gilad Shnoor
  • 374
  • 3
  • 12
1

Use FlatList for rendering Chats this will improve your performance over ScrollView. Flatlist vs ScrollView

Use inverted prop of Flatlist to invert it. And after that use onEndReached prop in that call your loadMoreMessage function. When your FlatList is inverted your onEndReached would be called when you reach the top.

rishikesh_07
  • 889
  • 9
  • 16