Here's the hook which returns the data based on the page
const {
data,
isFetching,
isLoading,
isError,
} = useGetResourceQuery(page, perPage );
here's the api
export const api = createApi({
baseQuery: fetchBaseQuery({
baseUrl: "http://localhost:3001",
}),
tagTypes: ["resource"],
endpoints: (build) => ({
getResource: build.query({
query: (page = 1, perPage = 20) =>
`resource?spage=${page}&limit=${perPage}`,
}),
}),
});
export const {useGetResourceQuery} = api
Is there any way we can extract the state of all the queries? I want to implement pagination based on scroll (infinite scroll) Do we need to update the middleware? or are there any ways to access the state and expose it as a function above, I went through the documentation but couldn't find a solution
I can use local state and concatenate them but wanted to know if it's possible using RTK
Thanks
createApi
method is part of our new "RTK Query" API in Redux Toolkit 1.6, just released this week: redux-toolkit.js.org/rtk-query/overview – PyrognosticsuseResourceQuery(1)
touseResourceQuery(2)
, that's two separate response datasets. Might be worth filing a feature request issue. – Pyrognostics