You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thank you so much for the amazing package,
I'm trying to implement it with react-query for a chat application.
Basically, we need to first load most recent messages and when user scrolls to the top of the container, we load old messages.
Just like whatsapp.
I got the load on scroll working and everything is fine.
Just having one small issue:
What happens is on the Initial data load by react-query the container's scroll position is at the top.
And our sentryRef element is also on the top, that triggers loadMore and after loading more still the scroll position stays at top and it just keeps loading more and more, until all the data is loaded.
could you please provide a solution to this problem 😢.
Thanks for your intereset to this package and also for this issue 🙏
If I understood the problem correctly, you need to handle the scroll position.
If you go to the demo and select Reversed Vertically Scrollable List for "List Type", you can see the behavior is similar to what would be expected from a chat.
Basically, you need an useEffect which will update the scroll position after the new items are loaded and an onScroll handler to keep track of the current scroll position. And don't forget to set both scrollableRootRef and infiniteRef by using a useCallback (like here) to prevent any performance issues.
I think you will get it when you see the code 😄
And I see that these examples are a little scattered all around and people may miss them. So I'm planning to add these to the README.md or update the demo site to be more explicit.
I hope this helps you to solve the problem. If you have any further questions or if this answer solves the problem, please comment 🙏
I'll keep this issue open until I improve the documentation of these examples.
Hi,
First of all thank you so much for the amazing package,
I'm trying to implement it with
react-query
for a chat application.Basically, we need to first load most recent messages and when user scrolls to the top of the container, we load old messages.
Just like whatsapp.
I got the load on scroll working and everything is fine.
Just having one small issue:
What happens is on the Initial data load by
react-query
the container's scroll position is at the top.And our
sentryRef
element is also on the top, that triggersloadMore
and after loading more still the scroll position stays at top and it just keeps loading more and more, until all the data is loaded.could you please provide a solution to this problem 😢.
Thank you.
Here's the code:
The text was updated successfully, but these errors were encountered: