@ventlio/tanstack-query 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -107,8 +107,11 @@ export const useGetRequest = <TResponse extends Record<string, any>>({
|
|
|
107
107
|
}, [keyTracker, requestPath, queryClient, queryOptions?.staleTime]);
|
|
108
108
|
|
|
109
109
|
const nextPage = () => {
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const queryData = query.data;
|
|
111
|
+
const data = queryData ?? queryClient.getQueryData([requestPath, {}]);
|
|
112
|
+
|
|
113
|
+
if (data?.data.pagination) {
|
|
114
|
+
const pagination: IPagination = data.data.pagination;
|
|
112
115
|
if (pagination.next_page !== pagination.current_page && pagination.next_page > pagination.current_page) {
|
|
113
116
|
setRequestPath(constructPaginationLink(requestPath, pagination.next_page));
|
|
114
117
|
}
|
|
@@ -116,8 +119,10 @@ export const useGetRequest = <TResponse extends Record<string, any>>({
|
|
|
116
119
|
};
|
|
117
120
|
|
|
118
121
|
const prevPage = () => {
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
const queryData = query.data;
|
|
123
|
+
const data = queryData ?? queryClient.getQueryData([requestPath, {}]);
|
|
124
|
+
if (data?.data.pagination) {
|
|
125
|
+
const pagination: IPagination = data.data.pagination;
|
|
121
126
|
if (pagination.previous_page !== pagination.current_page && pagination.previous_page < pagination.current_page) {
|
|
122
127
|
setRequestPath(constructPaginationLink(requestPath, pagination.previous_page));
|
|
123
128
|
}
|