Back

Infinite scrolling implementation.

  • 0
  • Web
joujou
27 Jun, 2024, 11:02

Hello. I'm currently building this app which in the 'All' page where all the posts are displayed, I am implementing infinitequery. The error I'm getting is getNextPageParam accepting type error. The problem is because getNextPageParam() callback is expecting a number but Appwrite query method for infinite scrolling pagination Query.cursorAfter is accepting string as argument. I've tried everything, including chatGPt for help to no avail. Typescript is complaining this error obviously and its the only error in my app that's failing in production. It works on development however. Here is the link to the gist. Any help is greatly appreciated. it's very frustrating really... when i console.log(lastpage), lastPage is an object { total: number, documents: [{...}] } https://gist.github.com/joujou144/7a6358e447aa08d4a4bae221fa6b0212

TL;DR
Developers are struggling with implementing infinite scrolling due to a type error between getNextPageParam and Query.cursorAfter in TypeScript. The issue is causing errors in production but not in development. The confusion seems to stem from pageParams and documentId in pagination. Solution: Ensure the correct data types are being passed between functions.
Joshi
27 Jun, 2024, 11:30

What is pageParams supposed to be? Is that the id of a document? It sounds more like you confused the two types of pagination

Joshi
27 Jun, 2024, 11:31

cursorAfter requires the documentId aka the documentId where it should continue

Joshi
27 Jun, 2024, 11:31

Offset pagination uses integer to paginate

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more