@@ -43,15 +43,14 @@ export function infiniteQueryBehavior<
43
43
cancelFn = ( queryFnResult as any ) . cancel
44
44
}
45
45
46
- const promise = Promise . resolve ( queryFnResult )
47
- . then ( page => {
48
- newPageParams = previous
49
- ? [ param , ...newPageParams ]
50
- : [ ...newPageParams , param ]
51
- return previous ? [ page , ...pages ] : [ ...pages , page ]
52
- } )
46
+ const promise = Promise . resolve ( queryFnResult ) . then ( page => {
47
+ newPageParams = previous
48
+ ? [ param , ...newPageParams ]
49
+ : [ ...newPageParams , param ]
50
+ return previous ? [ page , ...pages ] : [ ...pages , page ]
51
+ } )
53
52
if ( cancelFn ) {
54
- ( promise as any ) . cancel = cancelFn
53
+ ; ( promise as any ) . cancel = cancelFn
55
54
}
56
55
return promise
57
56
}
@@ -101,11 +100,14 @@ export function infiniteQueryBehavior<
101
100
}
102
101
}
103
102
104
- const finalPromise = promise . then ( pages => ( { pages, pageParams : newPageParams } ) )
103
+ const finalPromise = promise . then ( pages => ( {
104
+ pages,
105
+ pageParams : newPageParams ,
106
+ } ) )
105
107
if ( ( promise as any ) . cancel ) {
106
- ( finalPromise as any ) . cancel = ( promise as any ) . cancel ;
108
+ ; ( finalPromise as any ) . cancel = ( promise as any ) . cancel
107
109
}
108
- return finalPromise ;
110
+ return finalPromise
109
111
}
110
112
} ,
111
113
}
@@ -133,9 +135,14 @@ export function hasNextPage(
133
135
options : QueryOptions < any , any > ,
134
136
pages ?: unknown
135
137
) : boolean | undefined {
136
- return options . getNextPageParam && Array . isArray ( pages )
137
- ? typeof getNextPageParam ( options , pages ) !== 'undefined'
138
- : undefined
138
+ if ( options . getNextPageParam && Array . isArray ( pages ) ) {
139
+ const nextPageParam = getNextPageParam ( options , pages )
140
+ return (
141
+ typeof nextPageParam !== 'undefined' &&
142
+ nextPageParam !== null &&
143
+ nextPageParam !== false
144
+ )
145
+ }
139
146
}
140
147
141
148
/**
@@ -146,7 +153,12 @@ export function hasPreviousPage(
146
153
options : QueryOptions < any , any > ,
147
154
pages ?: unknown
148
155
) : boolean | undefined {
149
- return options . getPreviousPageParam && Array . isArray ( pages )
150
- ? typeof getPreviousPageParam ( options , pages ) !== 'undefined'
151
- : undefined
156
+ if ( options . getPreviousPageParam && Array . isArray ( pages ) ) {
157
+ const previousPageParam = getPreviousPageParam ( options , pages )
158
+ return (
159
+ typeof previousPageParam !== 'undefined' &&
160
+ previousPageParam !== null &&
161
+ previousPageParam !== false
162
+ )
163
+ }
152
164
}
0 commit comments