Trying to implement infinite scroll with infinite query

So i was looking at this video to see how this guy implememented infintie scroll: https://www.youtube.com/watch?v=nzJsYJPCc80&t=3592s (his github repo in description, and the part of the video is labeled), and the way he made it is kind of glitchy, when I scroll down, it just fetches the same data over and over which happens in his video as well, and when I print the nextcursor, which is the id of the next record, its always the same for some reason. I pretty much have the same code as him except I just have my own schema that i use instead of tweet, which shouldn't make a difference at all.
TomDoesTech
YouTube
Build a Twitter Clone with the T3 Stack - tRPC, Next.js, Prisma, Ta...
Repository: https://github.com/TomDoesTech/t3-twitter-clone 0:00 - Intro 1:06 - Bootstrap application 7:28 - Discord OAuth 10:41 - Create Tweet 35:35 - Seed database 37:40 - List Tweets 51:50 - Format dates with Day.js 54:00 - Cursor-based pagination 56:51 - Infinite scroll (useInfiniteQuery) 1:05:25 - Like & Unlike Tweet 1:17:38 - Update cach...
1 Reply
isaac_way
isaac_way2y ago
nextCursor should just be a parameter that your server returns that lets it know where the next page should start whenever it gets passed back to the server. IE if the first page returns the first 10 items, nextCursor could be set to the ID of the 10th tweet, and when the server receives that ID back from the front end it should query starting at that ID. So one of those two things must be going wrong I briefly looked at his code, couldn't tell what was wrong at first glance
Want results from more Discord servers?
Add your server