-
Notifications
You must be signed in to change notification settings - Fork 64
Pagination fails with no results #41
Comments
Can you paste a log of the state metadata in your response body here? |
You don't have to return so many states in your response body, you just have to return |
Returning |
It seems that issue with processing 0 in totalRecords is about totalPages calculation: Assuming that firstPage === 1 for empty response, should the totalPages become 1 also? |
Why would an empty response indicate having > 0 number of pages? |
Considering the following condition: The state has firstPage === 1, currentPage === 1 and firstPage === 1. Passing condition leads to RangeError throwing. So there are two approaches: keep all related state properties actual (being 0) in case of totalRecords === 0 or force totalPages = 1 in this case. As for me, server API should response only with total_entries === 0 in case of empty collection (e.g. after filtration). So the question is: should it be treated as first and single page (totalPages === 1)? If not, then the only way is to respond with total_entries === null (which makes server API less consistent). |
The better question is, under what circumstances would you ever reach that state by using the paginator's methods? Are you manually fiddling the state yourself? |
Yes, I'm setting state.currentPage = 1. But before fetching the filtered results. |
Would this work for you? else if (firstPage === 1 && (currentPage < firstPage || currentPage > totalPages && totalPages > 0)) { |
Also, which mode are you using? |
I'm using the "server" mode and yes - this condition works. So the question is about which workaround to use - |
Can you obtain a grain of salt from an empty jar? That's a contradiction. I'll commit a fix for this. Thanks for letting me know. |
But a jar is not supposed to disappear due to lack of salt :) Anyway, thanks a lot. |
What if ? I am getting same issue! Plz help! |
How can you have a totalRecords of 5, a pageSize of 10 and be on page 4? Of course you get an error. |
I'm using pagination with a filter which means my API needs to return zero results sometimes. This causes the following Range Error to be thrown:
Where:
Even if I set totalPages to 1 in my API it gets set to zero which is causing the error to be thrown.
The text was updated successfully, but these errors were encountered: