useQueries and useInfiniteQuery combination help #7133
Replies: 2 comments 6 replies
-
I don't understand the question. Please show a reproduction |
Beta Was this translation helpful? Give feedback.
-
Okey, think that I have an api which returns me different things based on the endpoint. In that case, I want to fetch those all in parallel with const result = useQueries({
queries: endpoints.map((endpoint) => ({
queryKey: [endpoint],
queryFn: ({pageParam}) => fetchFn(endpoint,pageParam),
}))
}); Now I have a result with those three api's responses. Think that, each response contains hundreds objects of an array like Instead of querying like that I want to use pagination since my endpoints have pagination option. Each time I will fetch 10 object of an array on related endpoints. You can see my fetchFn below const fetchFn = async (endpoint,pageParam)=>{
let apiUrl = `..../${endpoint}?skip=${pageParam * 10}&take=10`;
const result = await axios.get(apiUrl);
return result.data However, in order to do pagination and infinite scroll logic via tanstack query, I should use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
is there a way to combine those two hooks? I am trying to fetch multiple queries and also want to handle a logic with infinite scrolling through those data. I need an hook like useInfiniteQueries to handle this logic :) otherwise for 4 different fetch, I will write a same logic with useInfiniteQuery, that looks dirty on code ( four times useInfiniteQuery logic with different four fetches)
Beta Was this translation helpful? Give feedback.
All reactions