File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,14 @@ export function useQuery<
173
173
}
174
174
175
175
previousResult = result ;
176
+
177
+ if ( ! result . loading ) {
178
+ if ( result . data ) {
179
+ ref . current . options ?. onCompleted ?.( result . data ) ;
180
+ } else if ( result . error ) {
181
+ ref . current . options ?. onError ?.( result . error ) ;
182
+ }
183
+ }
176
184
}
177
185
178
186
return previousResult ;
@@ -191,23 +199,6 @@ export function useQuery<
191
199
} ) , [ obsQuery ] ) ;
192
200
193
201
let result = useSyncExternalStore ( subscribe , getSnapshot , getSnapshot ) ;
194
- useEffect ( ( ) => {
195
- if (
196
- ref . current . options ?. skip ||
197
- ref . current . options ?. fetchPolicy === 'standby'
198
- ) {
199
- return ;
200
- }
201
-
202
- if ( ! result . loading ) {
203
- if ( result . error ) {
204
- ref . current . options ?. onError ?.( result . error ) ;
205
- } else if ( result . data ) {
206
- ref . current . options ?. onCompleted ?.( result . data ) ;
207
- }
208
- }
209
- } , [ result ] ) ;
210
-
211
202
let partial : boolean | undefined ;
212
203
( { partial, ...result } = result ) ;
213
204
if ( options ?. skip || options ?. fetchPolicy === 'standby' ) {
You can’t perform that action at this time.
0 commit comments