3👍
✅
From the code you’ve shared the function getMorePosts()
gets the first three posts and finds the last post. Then it queries the next 3 posts using the last visible
document in the first query as the cursor.
The problem is the function always performs the same activity to fetch the first 3 posts and get the next 3 posts every time when you scroll to the bottom.
One way to solve this problem is to pass the last visible as a parameter to the function.
So initially the last visible
document can be empty and then the query the posts and the query’s last visible
document can be passed as the parameter to load more posts and so on.
Hope that helps.
Source:stackexchange.com