InfiniteQuery, Offset+Limit endpoints, & virtual scrolling #2747
Unanswered
wraybowling
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a two-fold problem:
1st: I'm working with paginated APIs that don't return a new cursor in the response. They don't use pages. Instead, I can make a request that's similar to making a SQL query.
Input Parameters:
Output:
I think that InfiniteQuery is the right hook to use, but the nextPage and prevPage and cursor returned stuff doesn't make sense for the API i'm working with. I've tried to find someone else talking about how to adapt it for this alternative style to pagination and i'm not finding examples that line up.
The other issue I'm not sure how to resolve is that what I actually want is something that might not exist. I want the data array to be the length of total_count right from the beginning. A component using virtual scrolling will then render the data in buckets that don't necessarily line up with the paginated data. All that matters is that scrolling in the component updates the cursor in the query so that data at that sector is pulled.
This seems like it would be really common for a lot of use cases, but in particular I'd like to use the Ant Design Select https://ant.design/components/select/#components-select-demo-big-data and update the cursor via onPopupScroll.
So, to review in reverse, stepping through it from UI interaction to API call,
y
position,y
by32
to find theoffset
item.offset
bylimit
to create apage
, reducing the number of api callsIf InfiniteQuery has a way to directly tell it which page to use, even if previous pages haven't been populated, that would be ideal. Part of the problem is that those slots in the data array need to exist or else virtual scrolling won't calculate the correct y height.
Beta Was this translation helpful? Give feedback.
All reactions