@ventlio/tanstack-query 0.2.77 → 0.2.78
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/dist/index.mjs +24 -6
- package/dist/index.mjs.map +1 -1
- package/dist/queries/useGetInfiniteRequest.d.ts +20 -7
- package/dist/queries/useGetInfiniteRequest.js +25 -7
- package/dist/queries/useGetInfiniteRequest.js.map +1 -1
- package/package.json +1 -1
- package/src/queries/useGetInfiniteRequest.ts +49 -8
package/dist/index.mjs
CHANGED
|
@@ -436,6 +436,8 @@ const useDeleteRequest = (deleteOptions) => {
|
|
|
436
436
|
const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl, headers, }) => {
|
|
437
437
|
const { API_URL, TIMEOUT } = useEnvironmentVariables();
|
|
438
438
|
const { getHeaders } = useQueryHeaders();
|
|
439
|
+
const [requestPath, updatePath] = useState(path);
|
|
440
|
+
const [options, setOptions] = useState(queryOptions);
|
|
439
441
|
let queryClient = useQueryClient();
|
|
440
442
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
441
443
|
queryClient = useMemo(() => queryClient, []);
|
|
@@ -444,7 +446,7 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
|
|
|
444
446
|
// get request headers
|
|
445
447
|
const globalHeaders = getHeaders();
|
|
446
448
|
const getResponse = await makeRequest({
|
|
447
|
-
path: pageParam ??
|
|
449
|
+
path: pageParam ?? requestPath,
|
|
448
450
|
headers: { ...globalHeaders, ...headers },
|
|
449
451
|
baseURL: baseUrl ?? API_URL,
|
|
450
452
|
timeout: TIMEOUT,
|
|
@@ -465,18 +467,33 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
|
|
|
465
467
|
* This pagination implementation is currently tied to our use case
|
|
466
468
|
*/
|
|
467
469
|
const constructPaginationLink = (direction, lastPage) => {
|
|
468
|
-
const [pathname, queryString] =
|
|
470
|
+
const [pathname, queryString] = requestPath.split('?');
|
|
469
471
|
const queryParams = new URLSearchParams(queryString);
|
|
470
472
|
const lastPageItem = lastPage.data.pagination[direction];
|
|
471
473
|
queryParams.set('page', String(lastPageItem));
|
|
472
474
|
return pathname + '?' + queryParams.toString();
|
|
473
475
|
};
|
|
474
|
-
const query = useInfiniteQuery([
|
|
476
|
+
const query = useInfiniteQuery([requestPath, {}], ({ pageParam = requestPath }) => new Promise((res, rej) => sendRequest(res, rej, pageParam)), {
|
|
475
477
|
enabled: load,
|
|
476
478
|
getNextPageParam: (lastPage) => constructPaginationLink('next_page', lastPage),
|
|
477
479
|
getPreviousPageParam: (lastPage) => constructPaginationLink('previous_page', lastPage),
|
|
478
|
-
...
|
|
480
|
+
...options,
|
|
479
481
|
});
|
|
482
|
+
const setOptionsAsync = async (fetchOptions) => {
|
|
483
|
+
startTransition(() => {
|
|
484
|
+
setOptions(fetchOptions);
|
|
485
|
+
});
|
|
486
|
+
};
|
|
487
|
+
const get = async (link, fetchOptions) => {
|
|
488
|
+
await setOptionsAsync(fetchOptions);
|
|
489
|
+
await updatedPathAsync(link);
|
|
490
|
+
return query.data;
|
|
491
|
+
};
|
|
492
|
+
const updatedPathAsync = async (link) => {
|
|
493
|
+
startTransition(() => {
|
|
494
|
+
updatePath(link);
|
|
495
|
+
});
|
|
496
|
+
};
|
|
480
497
|
useEffect(() => {
|
|
481
498
|
if (keyTracker) {
|
|
482
499
|
// set expiration time for the tracker
|
|
@@ -484,10 +501,11 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
|
|
|
484
501
|
cacheTime: Infinity,
|
|
485
502
|
staleTime: Infinity,
|
|
486
503
|
});
|
|
487
|
-
queryClient.setQueryData([keyTracker], [
|
|
504
|
+
queryClient.setQueryData([keyTracker], [requestPath, {}]);
|
|
488
505
|
}
|
|
489
|
-
}, [keyTracker,
|
|
506
|
+
}, [keyTracker, requestPath, queryClient, queryOptions?.staleTime]);
|
|
490
507
|
return {
|
|
508
|
+
get,
|
|
491
509
|
...query,
|
|
492
510
|
};
|
|
493
511
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InfiniteData, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { IRequestError, IRequestSuccess } from '../request';
|
|
2
3
|
import type { DefaultRequestOptions, TanstackInfiniteQueryOption } from './queries.interface';
|
|
3
4
|
interface Pagination {
|
|
4
5
|
previous_page: number;
|
|
@@ -48,11 +49,14 @@ export declare const useGetInfiniteRequest: <TResponse extends Record<string, an
|
|
|
48
49
|
isPreviousData: boolean;
|
|
49
50
|
isRefetching: boolean;
|
|
50
51
|
isStale: boolean;
|
|
51
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<
|
|
52
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<InfiniteData<IRequestSuccess<TResponse & {
|
|
52
53
|
pagination: Pagination;
|
|
53
54
|
}>>, any>>;
|
|
54
55
|
remove: () => void;
|
|
55
56
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
57
|
+
get: (link: string, fetchOptions?: UseQueryOptions<IRequestSuccess<TResponse | undefined>, IRequestError, IRequestSuccess<TResponse | undefined>, any[]> | undefined) => Promise<InfiniteData<IRequestSuccess<TResponse & {
|
|
58
|
+
pagination: Pagination;
|
|
59
|
+
}>> | undefined>;
|
|
56
60
|
} | {
|
|
57
61
|
data: undefined;
|
|
58
62
|
error: null;
|
|
@@ -86,13 +90,16 @@ export declare const useGetInfiniteRequest: <TResponse extends Record<string, an
|
|
|
86
90
|
isPreviousData: boolean;
|
|
87
91
|
isRefetching: boolean;
|
|
88
92
|
isStale: boolean;
|
|
89
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<
|
|
93
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<InfiniteData<IRequestSuccess<TResponse & {
|
|
90
94
|
pagination: Pagination;
|
|
91
95
|
}>>, any>>;
|
|
92
96
|
remove: () => void;
|
|
93
97
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
98
|
+
get: (link: string, fetchOptions?: UseQueryOptions<IRequestSuccess<TResponse | undefined>, IRequestError, IRequestSuccess<TResponse | undefined>, any[]> | undefined) => Promise<InfiniteData<IRequestSuccess<TResponse & {
|
|
99
|
+
pagination: Pagination;
|
|
100
|
+
}>> | undefined>;
|
|
94
101
|
} | {
|
|
95
|
-
data:
|
|
102
|
+
data: InfiniteData<IRequestSuccess<TResponse & {
|
|
96
103
|
pagination: Pagination;
|
|
97
104
|
}>>;
|
|
98
105
|
error: any;
|
|
@@ -126,13 +133,16 @@ export declare const useGetInfiniteRequest: <TResponse extends Record<string, an
|
|
|
126
133
|
isPreviousData: boolean;
|
|
127
134
|
isRefetching: boolean;
|
|
128
135
|
isStale: boolean;
|
|
129
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<
|
|
136
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<InfiniteData<IRequestSuccess<TResponse & {
|
|
130
137
|
pagination: Pagination;
|
|
131
138
|
}>>, any>>;
|
|
132
139
|
remove: () => void;
|
|
133
140
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
141
|
+
get: (link: string, fetchOptions?: UseQueryOptions<IRequestSuccess<TResponse | undefined>, IRequestError, IRequestSuccess<TResponse | undefined>, any[]> | undefined) => Promise<InfiniteData<IRequestSuccess<TResponse & {
|
|
142
|
+
pagination: Pagination;
|
|
143
|
+
}>> | undefined>;
|
|
134
144
|
} | {
|
|
135
|
-
data:
|
|
145
|
+
data: InfiniteData<IRequestSuccess<TResponse & {
|
|
136
146
|
pagination: Pagination;
|
|
137
147
|
}>>;
|
|
138
148
|
error: null;
|
|
@@ -166,10 +176,13 @@ export declare const useGetInfiniteRequest: <TResponse extends Record<string, an
|
|
|
166
176
|
isPreviousData: boolean;
|
|
167
177
|
isRefetching: boolean;
|
|
168
178
|
isStale: boolean;
|
|
169
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<
|
|
179
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<InfiniteData<IRequestSuccess<TResponse & {
|
|
170
180
|
pagination: Pagination;
|
|
171
181
|
}>>, any>>;
|
|
172
182
|
remove: () => void;
|
|
173
183
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
184
|
+
get: (link: string, fetchOptions?: UseQueryOptions<IRequestSuccess<TResponse | undefined>, IRequestError, IRequestSuccess<TResponse | undefined>, any[]> | undefined) => Promise<InfiniteData<IRequestSuccess<TResponse & {
|
|
185
|
+
pagination: Pagination;
|
|
186
|
+
}>> | undefined>;
|
|
174
187
|
};
|
|
175
188
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
-
import { useMemo, useEffect } from 'react';
|
|
2
|
+
import { useState, useMemo, useEffect, startTransition } from 'react';
|
|
3
3
|
import 'url-search-params-polyfill';
|
|
4
4
|
import { useEnvironmentVariables } from '../config/useEnvironmentVariables.js';
|
|
5
5
|
import { useQueryHeaders } from '../config/useQueryHeaders.js';
|
|
@@ -10,6 +10,8 @@ import '../request/request.enum.js';
|
|
|
10
10
|
const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl, headers, }) => {
|
|
11
11
|
const { API_URL, TIMEOUT } = useEnvironmentVariables();
|
|
12
12
|
const { getHeaders } = useQueryHeaders();
|
|
13
|
+
const [requestPath, updatePath] = useState(path);
|
|
14
|
+
const [options, setOptions] = useState(queryOptions);
|
|
13
15
|
let queryClient = useQueryClient();
|
|
14
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
17
|
queryClient = useMemo(() => queryClient, []);
|
|
@@ -18,7 +20,7 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
|
|
|
18
20
|
// get request headers
|
|
19
21
|
const globalHeaders = getHeaders();
|
|
20
22
|
const getResponse = await makeRequest({
|
|
21
|
-
path: pageParam ??
|
|
23
|
+
path: pageParam ?? requestPath,
|
|
22
24
|
headers: { ...globalHeaders, ...headers },
|
|
23
25
|
baseURL: baseUrl ?? API_URL,
|
|
24
26
|
timeout: TIMEOUT,
|
|
@@ -39,18 +41,33 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
|
|
|
39
41
|
* This pagination implementation is currently tied to our use case
|
|
40
42
|
*/
|
|
41
43
|
const constructPaginationLink = (direction, lastPage) => {
|
|
42
|
-
const [pathname, queryString] =
|
|
44
|
+
const [pathname, queryString] = requestPath.split('?');
|
|
43
45
|
const queryParams = new URLSearchParams(queryString);
|
|
44
46
|
const lastPageItem = lastPage.data.pagination[direction];
|
|
45
47
|
queryParams.set('page', String(lastPageItem));
|
|
46
48
|
return pathname + '?' + queryParams.toString();
|
|
47
49
|
};
|
|
48
|
-
const query = useInfiniteQuery([
|
|
50
|
+
const query = useInfiniteQuery([requestPath, {}], ({ pageParam = requestPath }) => new Promise((res, rej) => sendRequest(res, rej, pageParam)), {
|
|
49
51
|
enabled: load,
|
|
50
52
|
getNextPageParam: (lastPage) => constructPaginationLink('next_page', lastPage),
|
|
51
53
|
getPreviousPageParam: (lastPage) => constructPaginationLink('previous_page', lastPage),
|
|
52
|
-
...
|
|
54
|
+
...options,
|
|
53
55
|
});
|
|
56
|
+
const setOptionsAsync = async (fetchOptions) => {
|
|
57
|
+
startTransition(() => {
|
|
58
|
+
setOptions(fetchOptions);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const get = async (link, fetchOptions) => {
|
|
62
|
+
await setOptionsAsync(fetchOptions);
|
|
63
|
+
await updatedPathAsync(link);
|
|
64
|
+
return query.data;
|
|
65
|
+
};
|
|
66
|
+
const updatedPathAsync = async (link) => {
|
|
67
|
+
startTransition(() => {
|
|
68
|
+
updatePath(link);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
54
71
|
useEffect(() => {
|
|
55
72
|
if (keyTracker) {
|
|
56
73
|
// set expiration time for the tracker
|
|
@@ -58,10 +75,11 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
|
|
|
58
75
|
cacheTime: Infinity,
|
|
59
76
|
staleTime: Infinity,
|
|
60
77
|
});
|
|
61
|
-
queryClient.setQueryData([keyTracker], [
|
|
78
|
+
queryClient.setQueryData([keyTracker], [requestPath, {}]);
|
|
62
79
|
}
|
|
63
|
-
}, [keyTracker,
|
|
80
|
+
}, [keyTracker, requestPath, queryClient, queryOptions?.staleTime]);
|
|
64
81
|
return {
|
|
82
|
+
get,
|
|
65
83
|
...query,
|
|
66
84
|
};
|
|
67
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetInfiniteRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetInfiniteRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { InfiniteData, UseQueryOptions } from '@tanstack/react-query';
|
|
1
2
|
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
3
|
import type { RawAxiosRequestHeaders } from 'axios';
|
|
3
|
-
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { startTransition, useEffect, useMemo, useState } from 'react';
|
|
4
5
|
import { useEnvironmentVariables, useQueryHeaders } from '../config';
|
|
5
6
|
|
|
6
7
|
import type { IRequestError, IRequestSuccess } from '../request';
|
|
@@ -31,6 +32,9 @@ export const useGetInfiniteRequest = <TResponse extends Record<string, any>>({
|
|
|
31
32
|
} & DefaultRequestOptions) => {
|
|
32
33
|
const { API_URL, TIMEOUT } = useEnvironmentVariables();
|
|
33
34
|
const { getHeaders } = useQueryHeaders();
|
|
35
|
+
const [requestPath, updatePath] = useState<string>(path);
|
|
36
|
+
|
|
37
|
+
const [options, setOptions] = useState<any>(queryOptions);
|
|
34
38
|
|
|
35
39
|
let queryClient = useQueryClient();
|
|
36
40
|
|
|
@@ -52,7 +56,7 @@ export const useGetInfiniteRequest = <TResponse extends Record<string, any>>({
|
|
|
52
56
|
const globalHeaders: RawAxiosRequestHeaders = getHeaders();
|
|
53
57
|
|
|
54
58
|
const getResponse = await makeRequest<TResponse>({
|
|
55
|
-
path: pageParam ??
|
|
59
|
+
path: pageParam ?? requestPath,
|
|
56
60
|
headers: { ...globalHeaders, ...headers },
|
|
57
61
|
baseURL: baseUrl ?? API_URL,
|
|
58
62
|
timeout: TIMEOUT,
|
|
@@ -80,7 +84,7 @@ export const useGetInfiniteRequest = <TResponse extends Record<string, any>>({
|
|
|
80
84
|
}
|
|
81
85
|
>
|
|
82
86
|
) => {
|
|
83
|
-
const [pathname, queryString] =
|
|
87
|
+
const [pathname, queryString] = requestPath.split('?');
|
|
84
88
|
|
|
85
89
|
const queryParams = new URLSearchParams(queryString);
|
|
86
90
|
const lastPageItem = lastPage.data.pagination[direction];
|
|
@@ -91,8 +95,8 @@ export const useGetInfiniteRequest = <TResponse extends Record<string, any>>({
|
|
|
91
95
|
};
|
|
92
96
|
|
|
93
97
|
const query = useInfiniteQuery<any, any, IRequestSuccess<TResponse & { pagination: Pagination }>>(
|
|
94
|
-
[
|
|
95
|
-
({ pageParam =
|
|
98
|
+
[requestPath, {}],
|
|
99
|
+
({ pageParam = requestPath }) =>
|
|
96
100
|
new Promise<IRequestSuccess<TResponse & { pagination: Pagination }> | IRequestError>((res, rej) =>
|
|
97
101
|
sendRequest(res, rej, pageParam)
|
|
98
102
|
),
|
|
@@ -100,10 +104,46 @@ export const useGetInfiniteRequest = <TResponse extends Record<string, any>>({
|
|
|
100
104
|
enabled: load,
|
|
101
105
|
getNextPageParam: (lastPage) => constructPaginationLink('next_page', lastPage),
|
|
102
106
|
getPreviousPageParam: (lastPage) => constructPaginationLink('previous_page', lastPage),
|
|
103
|
-
...
|
|
107
|
+
...options,
|
|
104
108
|
}
|
|
105
109
|
);
|
|
106
110
|
|
|
111
|
+
const setOptionsAsync = async (fetchOptions: any) => {
|
|
112
|
+
startTransition(() => {
|
|
113
|
+
setOptions(fetchOptions);
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const get = async (
|
|
118
|
+
link: string,
|
|
119
|
+
fetchOptions?: UseQueryOptions<
|
|
120
|
+
IRequestSuccess<TResponse | undefined>,
|
|
121
|
+
IRequestError,
|
|
122
|
+
IRequestSuccess<TResponse | undefined>,
|
|
123
|
+
Array<any>
|
|
124
|
+
>
|
|
125
|
+
): Promise<
|
|
126
|
+
| InfiniteData<
|
|
127
|
+
IRequestSuccess<
|
|
128
|
+
TResponse & {
|
|
129
|
+
pagination: Pagination;
|
|
130
|
+
}
|
|
131
|
+
>
|
|
132
|
+
>
|
|
133
|
+
| undefined
|
|
134
|
+
> => {
|
|
135
|
+
await setOptionsAsync(fetchOptions);
|
|
136
|
+
await updatedPathAsync(link);
|
|
137
|
+
|
|
138
|
+
return query.data;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const updatedPathAsync = async (link: string) => {
|
|
142
|
+
startTransition(() => {
|
|
143
|
+
updatePath(link);
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
107
147
|
useEffect(() => {
|
|
108
148
|
if (keyTracker) {
|
|
109
149
|
// set expiration time for the tracker
|
|
@@ -112,11 +152,12 @@ export const useGetInfiniteRequest = <TResponse extends Record<string, any>>({
|
|
|
112
152
|
staleTime: Infinity,
|
|
113
153
|
});
|
|
114
154
|
|
|
115
|
-
queryClient.setQueryData([keyTracker], [
|
|
155
|
+
queryClient.setQueryData([keyTracker], [requestPath, {}]);
|
|
116
156
|
}
|
|
117
|
-
}, [keyTracker,
|
|
157
|
+
}, [keyTracker, requestPath, queryClient, queryOptions?.staleTime]);
|
|
118
158
|
|
|
119
159
|
return {
|
|
160
|
+
get,
|
|
120
161
|
...query,
|
|
121
162
|
};
|
|
122
163
|
};
|