@tanstack/react-query 5.28.12 → 5.28.13

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query",
3
- "version": "5.28.12",
3
+ "version": "5.28.13",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@
41
41
  "!build/codemods/**/__tests__"
42
42
  ],
43
43
  "dependencies": {
44
- "@tanstack/query-core": "5.28.12"
44
+ "@tanstack/query-core": "5.28.13"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/react": "^18.2.55",
@@ -10,7 +10,7 @@ import {
10
10
  import { act, render } from '@testing-library/react'
11
11
  import * as React from 'react'
12
12
  import { useSuspenseQueries } from '..'
13
- import { createQueryClient, sleep } from './utils'
13
+ import { createQueryClient, queryKey, renderWithClient, sleep } from './utils'
14
14
  import type { UseSuspenseQueryOptions } from '..'
15
15
 
16
16
  type NumberQueryOptions = UseSuspenseQueryOptions<number>
@@ -141,4 +141,45 @@ describe('useSuspenseQueries', () => {
141
141
  expect(onQueriesResolution).toHaveBeenCalledTimes(2)
142
142
  expect(onQueriesResolution).toHaveBeenLastCalledWith([3, 4, 5, 6])
143
143
  })
144
+
145
+ it('should only call combine after resolving', async () => {
146
+ const spy = vi.fn()
147
+ const key = queryKey()
148
+
149
+ function Page() {
150
+ const data = useSuspenseQueries({
151
+ queries: [1, 2, 3].map((value) => ({
152
+ queryKey: [...key, { value }],
153
+ queryFn: async () => {
154
+ await sleep(value * 10)
155
+ return { value: value * 10 }
156
+ },
157
+ })),
158
+ combine: (result) => {
159
+ spy(result)
160
+ return 'data'
161
+ },
162
+ })
163
+
164
+ return <h1>{data}</h1>
165
+ }
166
+
167
+ const rendered = renderWithClient(
168
+ queryClient,
169
+ <React.Suspense fallback="loading...">
170
+ <Page />
171
+ </React.Suspense>,
172
+ )
173
+
174
+ await act(() => vi.advanceTimersByTimeAsync(10))
175
+
176
+ rendered.getByText('loading...')
177
+
178
+ expect(spy).not.toHaveBeenCalled()
179
+
180
+ await act(() => vi.advanceTimersByTimeAsync(30))
181
+ rendered.getByText('data')
182
+
183
+ expect(spy).toHaveBeenCalled()
184
+ })
144
185
  })