@tanstack/react-query 5.0.0-beta.16 → 5.0.0-beta.18
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/build/codemods/coverage/clover.xml +2 -2
- package/build/codemods/coverage/index.html +1 -1
- package/package.json +2 -2
- package/src/__tests__/ssr.test.tsx +2 -2
- package/src/__tests__/suspense.test.tsx +1 -1
- package/src/__tests__/useInfiniteQuery.test.tsx +23 -23
- package/src/__tests__/useInfiniteQuery.type.test.tsx +10 -10
- package/src/__tests__/useQuery.test.tsx +5 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1692513610484" clover="3.2.0">
|
|
3
|
+
<project timestamp="1692513610484" name="All files">
|
|
4
4
|
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
|
|
5
5
|
</project>
|
|
6
6
|
</coverage>
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
87
87
|
Code coverage generated by
|
|
88
88
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
89
|
-
at 2023-08-
|
|
89
|
+
at 2023-08-20T06:40:10.454Z
|
|
90
90
|
</div>
|
|
91
91
|
<script src="prettify.js"></script>
|
|
92
92
|
<script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.18",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"client-only": "0.0.1",
|
|
45
|
-
"@tanstack/query-core": "5.0.0-beta.
|
|
45
|
+
"@tanstack/query-core": "5.0.0-beta.18"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/react": "^18.2.4",
|
|
@@ -132,7 +132,7 @@ describe('Server Side Rendering', () => {
|
|
|
132
132
|
queryKey: key,
|
|
133
133
|
queryFn,
|
|
134
134
|
getNextPageParam: () => undefined,
|
|
135
|
-
|
|
135
|
+
initialPageParam: 0,
|
|
136
136
|
})
|
|
137
137
|
return (
|
|
138
138
|
<ul>
|
|
@@ -146,7 +146,7 @@ describe('Server Side Rendering', () => {
|
|
|
146
146
|
await queryClient.prefetchInfiniteQuery({
|
|
147
147
|
queryKey: key,
|
|
148
148
|
queryFn,
|
|
149
|
-
|
|
149
|
+
initialPageParam: 0,
|
|
150
150
|
})
|
|
151
151
|
|
|
152
152
|
const markup = renderToString(
|
|
@@ -54,7 +54,7 @@ describe('useInfiniteQuery', () => {
|
|
|
54
54
|
queryKey: key,
|
|
55
55
|
queryFn: ({ pageParam }) => Number(pageParam),
|
|
56
56
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
57
|
-
|
|
57
|
+
initialPageParam: 0,
|
|
58
58
|
})
|
|
59
59
|
states.push(state)
|
|
60
60
|
return null
|
|
@@ -149,7 +149,7 @@ describe('useInfiniteQuery', () => {
|
|
|
149
149
|
retry: 1,
|
|
150
150
|
retryDelay: 10,
|
|
151
151
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
152
|
-
|
|
152
|
+
initialPageParam: start,
|
|
153
153
|
})
|
|
154
154
|
|
|
155
155
|
const { fetchNextPage } = state
|
|
@@ -186,7 +186,7 @@ describe('useInfiniteQuery', () => {
|
|
|
186
186
|
return `${pageParam}-${order}`
|
|
187
187
|
},
|
|
188
188
|
getNextPageParam: () => 1,
|
|
189
|
-
|
|
189
|
+
initialPageParam: 0,
|
|
190
190
|
placeholderData: keepPreviousData,
|
|
191
191
|
notifyOnChangeProps: 'all',
|
|
192
192
|
})
|
|
@@ -273,7 +273,7 @@ describe('useInfiniteQuery', () => {
|
|
|
273
273
|
pageParams: data.pageParams,
|
|
274
274
|
}),
|
|
275
275
|
getNextPageParam: () => undefined,
|
|
276
|
-
|
|
276
|
+
initialPageParam: 0,
|
|
277
277
|
})
|
|
278
278
|
states.push(state)
|
|
279
279
|
|
|
@@ -316,7 +316,7 @@ describe('useInfiniteQuery', () => {
|
|
|
316
316
|
}
|
|
317
317
|
}, []),
|
|
318
318
|
getNextPageParam: () => undefined,
|
|
319
|
-
|
|
319
|
+
initialPageParam: 0,
|
|
320
320
|
})
|
|
321
321
|
states.push(state)
|
|
322
322
|
|
|
@@ -364,7 +364,7 @@ describe('useInfiniteQuery', () => {
|
|
|
364
364
|
}),
|
|
365
365
|
notifyOnChangeProps: 'all',
|
|
366
366
|
getNextPageParam: () => 1,
|
|
367
|
-
|
|
367
|
+
initialPageParam: 0,
|
|
368
368
|
})
|
|
369
369
|
|
|
370
370
|
states.push(state)
|
|
@@ -416,7 +416,7 @@ describe('useInfiniteQuery', () => {
|
|
|
416
416
|
await sleep(10)
|
|
417
417
|
return Number(pageParam)
|
|
418
418
|
},
|
|
419
|
-
|
|
419
|
+
initialPageParam: start,
|
|
420
420
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
421
421
|
getPreviousPageParam: (firstPage) => firstPage - 1,
|
|
422
422
|
notifyOnChangeProps: 'all',
|
|
@@ -498,7 +498,7 @@ describe('useInfiniteQuery', () => {
|
|
|
498
498
|
await sleep(10)
|
|
499
499
|
return Number(pageParam)
|
|
500
500
|
},
|
|
501
|
-
|
|
501
|
+
initialPageParam: 10,
|
|
502
502
|
getPreviousPageParam: (firstPage) => firstPage - 1,
|
|
503
503
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
504
504
|
notifyOnChangeProps: 'all',
|
|
@@ -608,7 +608,7 @@ describe('useInfiniteQuery', () => {
|
|
|
608
608
|
await sleep(50)
|
|
609
609
|
return Number(pageParam)
|
|
610
610
|
},
|
|
611
|
-
|
|
611
|
+
initialPageParam: start,
|
|
612
612
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
613
613
|
})
|
|
614
614
|
|
|
@@ -664,7 +664,7 @@ describe('useInfiniteQuery', () => {
|
|
|
664
664
|
const { fetchNextPage } = useInfiniteQuery({
|
|
665
665
|
queryKey: key,
|
|
666
666
|
queryFn: fetchPage,
|
|
667
|
-
|
|
667
|
+
initialPageParam: start,
|
|
668
668
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
669
669
|
})
|
|
670
670
|
|
|
@@ -741,7 +741,7 @@ describe('useInfiniteQuery', () => {
|
|
|
741
741
|
const { fetchNextPage } = useInfiniteQuery({
|
|
742
742
|
queryKey: key,
|
|
743
743
|
queryFn: fetchPage,
|
|
744
|
-
|
|
744
|
+
initialPageParam: start,
|
|
745
745
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
746
746
|
})
|
|
747
747
|
|
|
@@ -797,7 +797,7 @@ describe('useInfiniteQuery', () => {
|
|
|
797
797
|
await sleep(50)
|
|
798
798
|
return Number(pageParam)
|
|
799
799
|
},
|
|
800
|
-
|
|
800
|
+
initialPageParam: start,
|
|
801
801
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
802
802
|
notifyOnChangeProps: 'all',
|
|
803
803
|
})
|
|
@@ -851,7 +851,7 @@ describe('useInfiniteQuery', () => {
|
|
|
851
851
|
return Number(pageParam) * 10
|
|
852
852
|
},
|
|
853
853
|
initialData,
|
|
854
|
-
|
|
854
|
+
initialPageParam: 0,
|
|
855
855
|
getNextPageParam: (_, allPages) => {
|
|
856
856
|
return allPages.length === 4 ? undefined : allPages.length
|
|
857
857
|
},
|
|
@@ -898,7 +898,7 @@ describe('useInfiniteQuery', () => {
|
|
|
898
898
|
return Number(pageParam)
|
|
899
899
|
},
|
|
900
900
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
901
|
-
|
|
901
|
+
initialPageParam: firstPage,
|
|
902
902
|
notifyOnChangeProps: 'all',
|
|
903
903
|
})
|
|
904
904
|
|
|
@@ -979,7 +979,7 @@ describe('useInfiniteQuery', () => {
|
|
|
979
979
|
},
|
|
980
980
|
initialData: { pages: [1], pageParams: [1] },
|
|
981
981
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
982
|
-
|
|
982
|
+
initialPageParam: 0,
|
|
983
983
|
notifyOnChangeProps: 'all',
|
|
984
984
|
})
|
|
985
985
|
|
|
@@ -1040,7 +1040,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1040
1040
|
queryKey: key,
|
|
1041
1041
|
queryFn: ({ pageParam }) => Number(pageParam),
|
|
1042
1042
|
getNextPageParam: () => undefined,
|
|
1043
|
-
|
|
1043
|
+
initialPageParam: 1,
|
|
1044
1044
|
})
|
|
1045
1045
|
|
|
1046
1046
|
states.push(state)
|
|
@@ -1079,7 +1079,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1079
1079
|
queryFn: ({ pageParam }): number => pageParam,
|
|
1080
1080
|
initialData: { pages: [10], pageParams: [10] },
|
|
1081
1081
|
getNextPageParam: (lastPage) => (lastPage === 10 ? 11 : undefined),
|
|
1082
|
-
|
|
1082
|
+
initialPageParam: 10,
|
|
1083
1083
|
})
|
|
1084
1084
|
|
|
1085
1085
|
states.push(state)
|
|
@@ -1116,7 +1116,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1116
1116
|
const state = useInfiniteQuery({
|
|
1117
1117
|
queryKey: key,
|
|
1118
1118
|
queryFn: ({ pageParam }): number => pageParam,
|
|
1119
|
-
|
|
1119
|
+
initialPageParam: 10,
|
|
1120
1120
|
initialData: { pages: [10], pageParams: [10] },
|
|
1121
1121
|
getNextPageParam: () => undefined,
|
|
1122
1122
|
})
|
|
@@ -1160,7 +1160,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1160
1160
|
pages: data.pages.map((x) => x.toString()),
|
|
1161
1161
|
pageParams: data.pageParams,
|
|
1162
1162
|
}),
|
|
1163
|
-
|
|
1163
|
+
initialPageParam: 1,
|
|
1164
1164
|
})
|
|
1165
1165
|
|
|
1166
1166
|
states.push(state)
|
|
@@ -1220,7 +1220,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1220
1220
|
queryKey: key,
|
|
1221
1221
|
queryFn: ({ pageParam }) =>
|
|
1222
1222
|
fetchItemsWithLimit(pageParam, fetchCountRef.current++),
|
|
1223
|
-
|
|
1223
|
+
initialPageParam: 0,
|
|
1224
1224
|
getNextPageParam: (lastPage) => lastPage.nextId,
|
|
1225
1225
|
})
|
|
1226
1226
|
|
|
@@ -1350,7 +1350,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1350
1350
|
pageParam === MAX || (pageParam === MAX - 1 && isRemovedLastPage),
|
|
1351
1351
|
),
|
|
1352
1352
|
getNextPageParam: (lastPage) => lastPage.nextId,
|
|
1353
|
-
|
|
1353
|
+
initialPageParam: 0,
|
|
1354
1354
|
})
|
|
1355
1355
|
|
|
1356
1356
|
return (
|
|
@@ -1472,7 +1472,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1472
1472
|
queryKey: key,
|
|
1473
1473
|
queryFn,
|
|
1474
1474
|
getNextPageParam: () => undefined,
|
|
1475
|
-
|
|
1475
|
+
initialPageParam: 0,
|
|
1476
1476
|
})
|
|
1477
1477
|
return (
|
|
1478
1478
|
<div>
|
|
@@ -1516,7 +1516,7 @@ describe('useInfiniteQuery', () => {
|
|
|
1516
1516
|
queryKey: key,
|
|
1517
1517
|
queryFn,
|
|
1518
1518
|
getNextPageParam: () => undefined,
|
|
1519
|
-
|
|
1519
|
+
initialPageParam: 0,
|
|
1520
1520
|
},
|
|
1521
1521
|
queryClient,
|
|
1522
1522
|
)
|
|
@@ -6,7 +6,7 @@ import type { Equal, Expect } from './utils'
|
|
|
6
6
|
import type { InfiniteData } from '@tanstack/query-core'
|
|
7
7
|
|
|
8
8
|
describe('pageParam', () => {
|
|
9
|
-
it('
|
|
9
|
+
it('initialPageParam should define type of param passed to queryFunctionContext', () => {
|
|
10
10
|
doNotExecute(() => {
|
|
11
11
|
useInfiniteQuery({
|
|
12
12
|
queryKey: ['key'],
|
|
@@ -14,7 +14,7 @@ describe('pageParam', () => {
|
|
|
14
14
|
const result: Expect<Equal<number, typeof pageParam>> = true
|
|
15
15
|
return result
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
initialPageParam: 1,
|
|
18
18
|
getNextPageParam: () => undefined,
|
|
19
19
|
})
|
|
20
20
|
})
|
|
@@ -30,7 +30,7 @@ describe('pageParam', () => {
|
|
|
30
30
|
> = true
|
|
31
31
|
return result
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
initialPageParam: 1,
|
|
34
34
|
getNextPageParam: () => undefined,
|
|
35
35
|
})
|
|
36
36
|
})
|
|
@@ -60,7 +60,7 @@ describe('pageParam', () => {
|
|
|
60
60
|
})
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
it('
|
|
63
|
+
it('initialPageParam should define type of param passed to queryFunctionContext for fetchInfiniteQuery', () => {
|
|
64
64
|
doNotExecute(() => {
|
|
65
65
|
const queryClient = new QueryClient()
|
|
66
66
|
queryClient.fetchInfiniteQuery({
|
|
@@ -69,12 +69,12 @@ describe('pageParam', () => {
|
|
|
69
69
|
const result: Expect<Equal<number, typeof pageParam>> = true
|
|
70
70
|
return result
|
|
71
71
|
},
|
|
72
|
-
|
|
72
|
+
initialPageParam: 1,
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
75
|
})
|
|
76
76
|
|
|
77
|
-
it('
|
|
77
|
+
it('initialPageParam should define type of param passed to queryFunctionContext for prefetchInfiniteQuery', () => {
|
|
78
78
|
doNotExecute(() => {
|
|
79
79
|
const queryClient = new QueryClient()
|
|
80
80
|
queryClient.prefetchInfiniteQuery({
|
|
@@ -83,7 +83,7 @@ describe('pageParam', () => {
|
|
|
83
83
|
const result: Expect<Equal<number, typeof pageParam>> = true
|
|
84
84
|
return result
|
|
85
85
|
},
|
|
86
|
-
|
|
86
|
+
initialPageParam: 1,
|
|
87
87
|
})
|
|
88
88
|
})
|
|
89
89
|
})
|
|
@@ -96,7 +96,7 @@ describe('select', () => {
|
|
|
96
96
|
queryFn: ({ pageParam }) => {
|
|
97
97
|
return pageParam * 5
|
|
98
98
|
},
|
|
99
|
-
|
|
99
|
+
initialPageParam: 1,
|
|
100
100
|
getNextPageParam: () => undefined,
|
|
101
101
|
})
|
|
102
102
|
|
|
@@ -119,7 +119,7 @@ describe('select', () => {
|
|
|
119
119
|
queryFn: ({ pageParam }) => {
|
|
120
120
|
return pageParam * 5
|
|
121
121
|
},
|
|
122
|
-
|
|
122
|
+
initialPageParam: 1,
|
|
123
123
|
getNextPageParam: () => undefined,
|
|
124
124
|
select: (data) => {
|
|
125
125
|
const result: Expect<
|
|
@@ -144,7 +144,7 @@ describe('getNextPageParam / getPreviousPageParam', () => {
|
|
|
144
144
|
queryFn: ({ pageParam }) => {
|
|
145
145
|
return String(pageParam)
|
|
146
146
|
},
|
|
147
|
-
|
|
147
|
+
initialPageParam: 1,
|
|
148
148
|
getNextPageParam: (
|
|
149
149
|
lastPage,
|
|
150
150
|
allPages,
|
|
@@ -2888,6 +2888,9 @@ describe('useQuery', () => {
|
|
|
2888
2888
|
})
|
|
2889
2889
|
|
|
2890
2890
|
it('should set status to error if queryFn throws', async () => {
|
|
2891
|
+
const consoleMock = vi
|
|
2892
|
+
.spyOn(console, 'error')
|
|
2893
|
+
.mockImplementation(() => undefined)
|
|
2891
2894
|
const key = queryKey()
|
|
2892
2895
|
|
|
2893
2896
|
function Page() {
|
|
@@ -2911,6 +2914,8 @@ describe('useQuery', () => {
|
|
|
2911
2914
|
|
|
2912
2915
|
await waitFor(() => rendered.getByText('error'))
|
|
2913
2916
|
await waitFor(() => rendered.getByText('Error test jaylen'))
|
|
2917
|
+
|
|
2918
|
+
consoleMock.mockRestore()
|
|
2914
2919
|
})
|
|
2915
2920
|
|
|
2916
2921
|
it('should throw error if queryFn throws and throwOnError is in use', async () => {
|