@tanstack/react-query 4.21.0 → 4.22.3
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/umd/index.development.js +2 -2
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +9 -7
- package/src/__tests__/suspense.test.tsx +4 -3
- package/src/__tests__/useInfiniteQuery.test.tsx +37 -16
- package/src/__tests__/useQueries.test.tsx +13 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.3",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"use-sync-external-store": "^1.2.0",
|
|
50
|
-
"@tanstack/query-core": "4.
|
|
50
|
+
"@tanstack/query-core": "4.22.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -63,10 +63,12 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
|
-
"clean": "
|
|
67
|
-
"test:
|
|
68
|
-
"test:
|
|
69
|
-
"test:
|
|
70
|
-
"test:dev": "pnpm run test:
|
|
66
|
+
"clean": "rimraf ./build",
|
|
67
|
+
"test:eslint": "eslint --ext .ts,.tsx ./src",
|
|
68
|
+
"test:types": "tsc",
|
|
69
|
+
"test:lib": "jest --config ./jest.config.ts",
|
|
70
|
+
"test:lib:dev": "pnpm run test:lib --watch",
|
|
71
|
+
"test:lib:publish": "pnpm run test:lib --collectCoverage false",
|
|
72
|
+
"build:types": "tsc --build"
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -151,7 +151,7 @@ describe("useQuery's in Suspense mode", () => {
|
|
|
151
151
|
useQuery(
|
|
152
152
|
key,
|
|
153
153
|
() => {
|
|
154
|
-
sleep(
|
|
154
|
+
sleep(50)
|
|
155
155
|
return 'data'
|
|
156
156
|
},
|
|
157
157
|
{ suspense: true },
|
|
@@ -1084,7 +1084,7 @@ describe('useQueries with suspense', () => {
|
|
|
1084
1084
|
queryKey: key1,
|
|
1085
1085
|
queryFn: async () => {
|
|
1086
1086
|
results.push('1')
|
|
1087
|
-
await sleep(
|
|
1087
|
+
await sleep(50)
|
|
1088
1088
|
return '1'
|
|
1089
1089
|
},
|
|
1090
1090
|
suspense: true,
|
|
@@ -1093,7 +1093,7 @@ describe('useQueries with suspense', () => {
|
|
|
1093
1093
|
queryKey: key2,
|
|
1094
1094
|
queryFn: async () => {
|
|
1095
1095
|
results.push('2')
|
|
1096
|
-
await sleep(
|
|
1096
|
+
await sleep(200)
|
|
1097
1097
|
return '2'
|
|
1098
1098
|
},
|
|
1099
1099
|
staleTime: 1000,
|
|
@@ -1101,6 +1101,7 @@ describe('useQueries with suspense', () => {
|
|
|
1101
1101
|
},
|
|
1102
1102
|
],
|
|
1103
1103
|
})
|
|
1104
|
+
|
|
1104
1105
|
return (
|
|
1105
1106
|
<div>
|
|
1106
1107
|
<h1>data: {result.map((it) => it.data ?? 'null').join(',')}</h1>
|
|
@@ -283,12 +283,15 @@ describe('useInfiniteQuery', () => {
|
|
|
283
283
|
}),
|
|
284
284
|
})
|
|
285
285
|
states.push(state)
|
|
286
|
-
|
|
286
|
+
|
|
287
|
+
return <div>{state.data?.pages.join(',')}</div>
|
|
287
288
|
}
|
|
288
289
|
|
|
289
|
-
renderWithClient(queryClient, <Page />)
|
|
290
|
+
const rendered = renderWithClient(queryClient, <Page />)
|
|
290
291
|
|
|
291
|
-
await
|
|
292
|
+
await waitFor(() => {
|
|
293
|
+
rendered.getByText('count: 1')
|
|
294
|
+
})
|
|
292
295
|
|
|
293
296
|
expect(states.length).toBe(2)
|
|
294
297
|
expect(states[0]).toMatchObject({
|
|
@@ -317,12 +320,21 @@ describe('useInfiniteQuery', () => {
|
|
|
317
320
|
}, []),
|
|
318
321
|
})
|
|
319
322
|
states.push(state)
|
|
320
|
-
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<div>
|
|
326
|
+
{state.data?.pages.map((page) => (
|
|
327
|
+
<div key={page.id}>count: {page.count}</div>
|
|
328
|
+
))}
|
|
329
|
+
</div>
|
|
330
|
+
)
|
|
321
331
|
}
|
|
322
332
|
|
|
323
|
-
renderWithClient(queryClient, <Page />)
|
|
333
|
+
const rendered = renderWithClient(queryClient, <Page />)
|
|
324
334
|
|
|
325
|
-
await
|
|
335
|
+
await waitFor(() => {
|
|
336
|
+
rendered.getByText('count: 1')
|
|
337
|
+
})
|
|
326
338
|
|
|
327
339
|
expect(states.length).toBe(2)
|
|
328
340
|
expect(selectCalled).toBe(1)
|
|
@@ -415,20 +427,29 @@ describe('useInfiniteQuery', () => {
|
|
|
415
427
|
|
|
416
428
|
states.push(state)
|
|
417
429
|
|
|
418
|
-
|
|
430
|
+
return (
|
|
431
|
+
<div>
|
|
432
|
+
<div>data: {state.data?.pages.join(',') ?? null}</div>
|
|
433
|
+
<button onClick={() => state.fetchPreviousPage()}>
|
|
434
|
+
fetch previous page
|
|
435
|
+
</button>
|
|
436
|
+
</div>
|
|
437
|
+
)
|
|
438
|
+
}
|
|
419
439
|
|
|
420
|
-
|
|
421
|
-
setActTimeout(() => {
|
|
422
|
-
fetchPreviousPage()
|
|
423
|
-
}, 20)
|
|
424
|
-
}, [fetchPreviousPage])
|
|
440
|
+
const rendered = renderWithClient(queryClient, <Page />)
|
|
425
441
|
|
|
426
|
-
|
|
427
|
-
|
|
442
|
+
await waitFor(() => {
|
|
443
|
+
rendered.getByText('data: 10')
|
|
444
|
+
})
|
|
428
445
|
|
|
429
|
-
|
|
446
|
+
fireEvent.click(
|
|
447
|
+
rendered.getByRole('button', { name: /fetch previous page/i }),
|
|
448
|
+
)
|
|
430
449
|
|
|
431
|
-
await
|
|
450
|
+
await waitFor(() => {
|
|
451
|
+
rendered.getByText('data: 9,10')
|
|
452
|
+
})
|
|
432
453
|
|
|
433
454
|
expect(states.length).toBe(4)
|
|
434
455
|
expect(states[0]).toMatchObject({
|
|
@@ -45,7 +45,7 @@ describe('useQueries', () => {
|
|
|
45
45
|
{
|
|
46
46
|
queryKey: key2,
|
|
47
47
|
queryFn: async () => {
|
|
48
|
-
await sleep(
|
|
48
|
+
await sleep(200)
|
|
49
49
|
return 2
|
|
50
50
|
},
|
|
51
51
|
},
|
|
@@ -1050,12 +1050,21 @@ describe('useQueries', () => {
|
|
|
1050
1050
|
],
|
|
1051
1051
|
})
|
|
1052
1052
|
results.push(result)
|
|
1053
|
-
|
|
1053
|
+
|
|
1054
|
+
return (
|
|
1055
|
+
<div>
|
|
1056
|
+
<div>data1: {result[0].data}</div>
|
|
1057
|
+
<div>data2: {result[1].data}</div>
|
|
1058
|
+
</div>
|
|
1059
|
+
)
|
|
1054
1060
|
}
|
|
1055
1061
|
|
|
1056
|
-
renderWithClient(queryClient, <Page />, { context })
|
|
1062
|
+
const rendered = renderWithClient(queryClient, <Page />, { context })
|
|
1057
1063
|
|
|
1058
|
-
await
|
|
1064
|
+
await waitFor(() => {
|
|
1065
|
+
rendered.getByText('data1: 1')
|
|
1066
|
+
rendered.getByText('data2: 2')
|
|
1067
|
+
})
|
|
1059
1068
|
|
|
1060
1069
|
expect(results[0]).toMatchObject([
|
|
1061
1070
|
{ data: undefined },
|