Sharing data betweem useQuery with useInfiniteQuery (continuation tokens)
Not sure if I am over thinking this but conceptually I need some advice on what to do. Between these two queries the underlying data is exactly the same.
Goal:
1. User navigates from component 1 which uses
2. I have a little helper function that retrieves cached data from that
If user was on page 3 for example, the
Now when
So I am not sure how to structure the query configuation.
Note: I pass in the continuation token as a
Goal:
1. User navigates from component 1 which uses
useQuery hook to component 2 which uses useInfiniteQuery2. I have a little helper function that retrieves cached data from that
useQuery hook and transforms it into initialData that useInfiniteQuery expects. This works perfectly on mount. If user was on page 3 for example, the
pageParams might look like this [undefined, abc123, defg123, hijk123]Each param is obviously the token that fetches the current page.Now when
useInfiniteQuery refetches due to staleness, I would want the pageParams to look exactly like this, it would fetch the current page defg123 and have those previous pageParams to fetch the previous page. So I am not sure how to structure the query configuation.
Note: I pass in the continuation token as a
search param for the page to fetch, and the data returned has the continuation token for the next page.