File tree Expand file tree Collapse file tree 3 files changed +31
-14
lines changed Expand file tree Collapse file tree 3 files changed +31
-14
lines changed Original file line number Diff line number Diff line change 1
- import { DefaultedQueryObserverOptions , RefetchPageFilters } from './types'
1
+ import { RefetchPageFilters } from './types'
2
2
import {
3
3
isServer ,
4
4
isValidTimeout ,
@@ -224,14 +224,7 @@ export class QueryObserver<
224
224
}
225
225
226
226
trackResult (
227
- result : QueryObserverResult < TData , TError > ,
228
- defaultedOptions : DefaultedQueryObserverOptions <
229
- TQueryFnData ,
230
- TError ,
231
- TData ,
232
- TQueryData ,
233
- TQueryKey
234
- >
227
+ result : QueryObserverResult < TData , TError >
235
228
) : QueryObserverResult < TData , TError > {
236
229
const trackedResult = { } as QueryObserverResult < TData , TError >
237
230
@@ -246,10 +239,6 @@ export class QueryObserver<
246
239
} )
247
240
} )
248
241
249
- if ( defaultedOptions . useErrorBoundary ) {
250
- this . trackedProps . add ( 'error' )
251
- }
252
-
253
242
return trackedResult
254
243
}
255
244
@@ -606,6 +595,10 @@ export class QueryObserver<
606
595
607
596
const includedProps = new Set ( notifyOnChangeProps ?? this . trackedProps )
608
597
598
+ if ( this . options . useErrorBoundary ) {
599
+ includedProps . add ( 'error' )
600
+ }
601
+
609
602
return Object . keys ( result ) . some ( key => {
610
603
const typedKey = key as keyof QueryObserverResult
611
604
const changed = result [ typedKey ] !== prevResult [ typedKey ]
Original file line number Diff line number Diff line change @@ -2672,6 +2672,30 @@ describe('useQuery', () => {
2672
2672
consoleMock . mockRestore ( )
2673
2673
} )
2674
2674
2675
+ it ( 'should update with data if we observe no properties and useErrorBoundary' , async ( ) => {
2676
+ const key = queryKey ( )
2677
+
2678
+ let result : UseQueryResult < string > | undefined
2679
+
2680
+ function Page ( ) {
2681
+ const query = useQuery ( key , ( ) => Promise . resolve ( 'data' ) , {
2682
+ useErrorBoundary : true ,
2683
+ } )
2684
+
2685
+ React . useEffect ( ( ) => {
2686
+ result = query
2687
+ } )
2688
+
2689
+ return null
2690
+ }
2691
+
2692
+ renderWithClient ( queryClient , < Page /> )
2693
+
2694
+ await sleep ( 10 )
2695
+
2696
+ expect ( result ?. data ) . toBe ( 'data' )
2697
+ } )
2698
+
2675
2699
it ( 'should set status to error instead of throwing when error should not be thrown' , async ( ) => {
2676
2700
const key = queryKey ( )
2677
2701
const consoleMock = mockConsoleError ( )
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ export function useBaseQuery<
134
134
135
135
// Handle result property usage tracking
136
136
if ( ! defaultedOptions . notifyOnChangeProps ) {
137
- result = observer . trackResult ( result , defaultedOptions )
137
+ result = observer . trackResult ( result )
138
138
}
139
139
140
140
return result
You can’t perform that action at this time.
0 commit comments