react queyr with maxPages and virtualized list
i am building a virtualized list using tanstack query's infinite scroll with maxPages of, for example, 3
using
virtuoso for this, scrolling works fine for fetching UNTIL we get to 3 pages, say we have
[a,b,c], when we fetch the new one, the array becomes [b,c,d], so when the new page loads, virtuoso places me at the end of d which causes another refetch because we are at the bottom of the list
this might be SUPER specific, but how could i make it so it knows that we were instead at the end of c?
i am aware i could scroll to the end of 'c' when the page loads, but if the user scrolls while the page is loading, it might just drag them back there which isnt great either i think
going crazy on this one, hopefully someone here has done something similar before 😄 thanks3 Replies
rare-sapphire•10mo ago
i think if you properly set a unique key for each page it fixes itself
genetic-orange•3mo ago
Having the same problem. Someone reported the same problem here:
https://discord.com/channels/719702312431386674/1264259740645457991
@TkDodo 🔮 any idea what we may be doing wrong?
extended-salmon•3mo ago
for what it's worth, I intended
maxPages to be used as something so that you don't need virtualiation because you keep fewer things in the dom
but all it does is remove a page at the beginning of the array and add a new one at the end. seems like virtualization libs don't like that?