File tree Expand file tree Collapse file tree 2 files changed +29
-14
lines changed Expand file tree Collapse file tree 2 files changed +29
-14
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
- import { InfiniteQueryObserver } from '@tanstack/query-core'
2
+ import { InfiniteQueryObserver , skipToken } from '@tanstack/query-core'
3
3
import { useBaseQuery } from './useBaseQuery'
4
4
import { defaultThrowOnError } from './suspense'
5
5
import type {
@@ -32,6 +32,12 @@ export function useSuspenseInfiniteQuery<
32
32
> ,
33
33
queryClient ?: QueryClient ,
34
34
) : UseSuspenseInfiniteQueryResult < TData , TError > {
35
+ if ( process . env . NODE_ENV !== 'production' ) {
36
+ if ( options . queryFn === skipToken ) {
37
+ console . error ( 'skipToken is not allowed for useSuspenseInfiniteQuery' )
38
+ }
39
+ }
40
+
35
41
return useBaseQuery (
36
42
{
37
43
...options ,
Original file line number Diff line number Diff line change 1
1
'use client'
2
+ import {
3
+ type DefaultError ,
4
+ type QueryClient ,
5
+ type QueryFunction ,
6
+ type ThrowOnError ,
7
+ skipToken ,
8
+ } from '@tanstack/query-core'
2
9
import { useQueries } from './useQueries'
3
10
import { defaultThrowOnError } from './suspense'
4
11
import type { UseSuspenseQueryOptions , UseSuspenseQueryResult } from './types'
5
- import type {
6
- DefaultError ,
7
- QueryClient ,
8
- QueryFunction ,
9
- ThrowOnError ,
10
- } from '@tanstack/query-core'
11
12
12
13
// Avoid TS depth-limit error in case of large array literal
13
14
type MAXIMUM_DEPTH = 20
@@ -190,13 +191,21 @@ export function useSuspenseQueries<
190
191
return useQueries (
191
192
{
192
193
...options ,
193
- queries : options . queries . map ( ( query ) => ( {
194
- ...query ,
195
- suspense : true ,
196
- throwOnError : defaultThrowOnError ,
197
- enabled : true ,
198
- placeholderData : undefined ,
199
- } ) ) ,
194
+ queries : options . queries . map ( ( query ) => {
195
+ if ( process . env . NODE_ENV !== 'production' ) {
196
+ if ( query . queryFn === skipToken ) {
197
+ console . error ( 'skipToken is not allowed for useSuspenseQueries' )
198
+ }
199
+ }
200
+
201
+ return {
202
+ ...query ,
203
+ suspense : true ,
204
+ throwOnError : defaultThrowOnError ,
205
+ enabled : true ,
206
+ placeholderData : undefined ,
207
+ }
208
+ } ) ,
200
209
} as any ,
201
210
queryClient ,
202
211
)
You can’t perform that action at this time.
0 commit comments