Skip to content

Commit bc116d3

Browse files
authored
2927 offline queries (#3006)
* feat(useQuery): offline queries remove defaultQueryObserverOptions because it is the same as defaultQueryOptions and we can just use that * feat(useQuery): offline queries setup dependent default values, to make it easier to work with them * feat(useQuery): offline queries basic changes to retryer: - pause the query before fetching depending upon networkMode - pause retries depending upon networkRetry * feat(useQuery): offline queries move networkRetry and networkMode defaults to the retryer creation, because we need the same for mutations * feat(useQuery): offline queries decouple focus and online manager: we're now informing caches of a focus when we're focussed, and about an online event if we come online; if the retryer continues, it can then decide to not fetch depending on our networkMode * feat(useQuery): offline queries expose isPaused on the queryResult and make sure isFetching is false when we are paused * feat(useQuery): offline queries knowing if we can fetch depends on if we are paused or not, as other conditions should apply also, rename options (not sure if that will stick though) * feat(useQuery): offline queries adjust existing tests for isPaused being exposed * feat(useQuery): offline queries fix existing test by setting options to emulate the previous behaviour, otherwise, with `mockNavigatorOnline` being set to false right from the start, the mutation would never fire off * feat(useQuery): offline queries adapt onOnline, onFocus tests to new behavior: they are now decoupled, and onOnline is always called even when not focused and vice versa. The retryer should make sure to not continue fetching if necessary * feat(useQuery): offline queries first test for networkMode * feat(useQuery): offline queries isFetching and isPaused are now derived and stored together in a fetchingState enum (idle, fetching, paused) * feat(useQuery): offline queries better networkMode api: online, always, offlineFirst (basically always but with paused retries) * feat(useQuery): offline queries more tests for networkMode: online * feat(useQuery): offline queries more tests for networkMode: online * feat(useQuery): offline queries tests for networkMode: always * feat(useQuery): offline queries fix tests that were influencing each other by using proper jest mocks for online and visibility state * add paused queries to the devtools.tsx * feat(useQuery): offline queries never stop pausing when continueFn is called. Initially, I only had this guard for when it's called from the outside, e.g. for onWindowFocus while still being offline, but we need this always because otherwise query cancellation can potentially continue a paused query * feat(useQuery): offline queries okay, pausing multiple times was a bad idea, continueFn() will be called eventually anyways * feat(useQuery): offline queries attempt at offline toggle button * feat(useQuery): offline queries different icons, padding, color * feat(useQuery): offline queries i messed up the icon order * feat(useQuery): offline queries guard against illegal state transitions: paused queries can unmount or get cancelled, in which case we shouldn't continue them, even if we dispatch the continue event * feat(useQuery): offline queries fix devtools tests, account for paused queries * Revert "feat(useQuery): offline queries" This reverts commit a647f64. * feat(useQuery): offline queries keep the do-not-start logic out of the run function, and thus out of promiseOrValue. if the promise has already been resolved in the meantime, e.g. because of a `cancel`, the run method will just do nothing, while the previous logic would've started to fetch * feat(useQuery): offline queries show inactive as higher priority than paused * feat(useQuery): offline queries make sure that optimistic results don't show an intermediate fetching state, but go opmistically to paused instead * feat(useQuery): offline queries real result needs to match optimistic result * feat(useQuery): offline queries stupid mistake * feat(useQuery): offline queries keep status color and status label in sync * feat(useQuery): offline queries make networkMode param mandatory for canFetch (and default to online internally) so that we can't screw that up again * feat(useQuery): offline queries make sure test "finishes" to avoid prints to the console if another test goes online again * feat(useQuery): offline queries move cancel function to the top, as it's no longer dependent on the promise since the `.cancel` function is gone; all we need is to abort the signal and reject the promise of the retryer * feat(useQuery): offline queries inline canContinue, because it's now only called if the query is in paused state anyways * feat(useQuery): offline queries avoid the impossible state by not calling config.onContinue for already resolved queries, as that would put them right into fetching state again, without actually fetching * feat(useQuery): offline queries let resolved querie continue, but don't put them in fetching state * feat(useQuery): offline queries fix merge conflict and invert condition because no-negated-condition * feat(useQuery): offline queries add test for abort signal consumed - different results expected for node < 15 where we don't have AbortController, thus can't consume the signal * feat(useQuery): offline queries online queries should not fetch if paused and we go online when cancelled and no refetchOnReconnect * feat(useQuery): offline queries gc test * feat(useQuery): offline queries offlineFirst test * feat(useQuery): offline queries mock useMediaQuery to get rid of unnecessary check in devtools - if window is defined, `matchMedia` is also defined * feat(useQuery): offline queries use a higher retryDelay to make test more stable, otherwise, it might start retrying before we "go offline" * feat(useQuery): offline queries improve devtools test: check if onClick props are being called * feat(useQuery): offline queries add devtools test for offline mock * feat(useQuery): offline queries offline mutations test * feat(useQuery): offline queries network mode docs (unfinished) * feat(useQuery): offline queries network mode docs * feat(useQuery): offline queries fix merge conflicts
1 parent fb13a05 commit bc116d3

30 files changed

+1355
-179
lines changed

docs/src/manifests/manifest.json

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
"path": "/guides/query-functions",
7676
"editUrl": "/guides/query-functions.md"
7777
},
78+
{
79+
"title": "Network Mode",
80+
"path": "/guides/network-mode",
81+
"editUrl": "/guides/network-mode.md"
82+
},
7883
{
7984
"title": "Parallel Queries",
8085
"path": "/guides/parallel-queries",

docs/src/pages/guides/migrating-to-react-query-4.md

+39-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To streamline all apis, we've decided to make all keys Arrays only:
2020

2121
### Separate hydration exports have been removed
2222

23-
With version [3.22.0](https://github.com/tannerlinsley/react-query/releases/tag/v3.22.0), hydration utilities moved into the react-query core. With v3, you could still use the old exports from `react-query/hydration`, but these exports have been removed with v4.
23+
With version [3.22.0](https://github.com/tannerlinsley/react-query/releases/tag/v3.22.0), hydration utilities moved into the React Query core. With v3, you could still use the old exports from `react-query/hydration`, but these exports have been removed with v4.
2424

2525
```diff
2626
- import { dehydrate, hydrate, useHydrate, Hydrate } from 'react-query/hydration'
@@ -29,7 +29,7 @@ With version [3.22.0](https://github.com/tannerlinsley/react-query/releases/tag/
2929

3030
### `notifyOnChangeProps` property no longer accepts `"tracked"` as a value
3131

32-
The `notifyOnChangeProps` option no longer accepts a `"tracked"` value. Instead, `useQuery` defaults to tracking properties. All queries using `notifyOnChangeProps: "tracked"` should be updated by removing this option.
32+
The `notifyOnChangeProps` option no longer accepts a `"tracked"` value. Instead, `useQuery` defaults to tracking properties. All queries using `notifyOnChangeProps: "tracked"` should be updated by removing this option.
3333

3434
If you would like to bypass this in any queries to emulate the v3 default behavior of re-rendering whenever a query changes, `notifyOnChangeProps` now accepts an `"all"` value to opt-out of the default smart tracking optimization.
3535

@@ -140,7 +140,7 @@ The `MutationCacheNotifyEvent` uses the same types as the `QueryCacheNotifyEvent
140140
141141
### The `src/react` directory was renamed to `src/reactjs`
142142

143-
Previously, react-query had a directory named `react` which imported from the `react` module. This could cause problems with some Jest configurations, resulting in errors when running tests like:
143+
Previously, React Query had a directory named `react` which imported from the `react` module. This could cause problems with some Jest configurations, resulting in errors when running tests like:
144144

145145
```
146146
TypeError: Cannot read property 'createContext' of undefined
@@ -161,7 +161,7 @@ This was confusing to many and also created infinite loops if `setQueryData` was
161161

162162
Similar to `onError` and `onSettled`, the `onSuccess` callback is now tied to a request being made. No request -> no callback.
163163

164-
If you want to listen to changes of the `data` field, you can best do this with a `useEffect`, where `data` is part of the dependency Array. Since react-query ensures stable data through structural sharing, the effect will not execute with every background refetch, but only if something within data has changed:
164+
If you want to listen to changes of the `data` field, you can best do this with a `useEffect`, where `data` is part of the dependency Array. Since React Query ensures stable data through structural sharing, the effect will not execute with every background refetch, but only if something within data has changed:
165165

166166
```
167167
const { data } = useQuery({ queryKey, queryFn })
@@ -188,8 +188,43 @@ Since these plugins are no longer experimental, their import paths have also bee
188188

189189
The [old `cancel` method](../guides/query-cancellation#old-cancel-function) that allowed you to define a `cancel` function on promises, which was then used by the library to support query cancellation, has been removed. We recommend to use the [newer API](../guides/query-cancellation) (introduced with v3.30.0) for query cancellation that uses the [`AbortController` API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) internally and provides you with an [`AbortSignal` instance](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for your query function to support query cancellation.
190190

191+
### Queries and mutations, per default, need network connection to run
192+
193+
Please read the [New Features announcement](#proper-offline-support) about online / offline support, and also the dedicated page about [Network mode](../guides/network-mode)
194+
195+
Even though React Query is an Async State Manager that can be used for anything that produces a Promise, it is most often used for data fetching in combination with data fetching libraries. That is why, per default, queries and mutations will be `paused` if there is no network connection. If you want to opt-in to the previous behavior, you can globally set `networkMode: offlineFirst` for both queries and mutations:
196+
197+
```js
198+
new QueryClient({
199+
defaultOptions: {
200+
queries: {
201+
networkMode: 'offlineFirst'
202+
},
203+
mutations: {
204+
networkmode: 'offlineFirst'
205+
}
206+
}
207+
})
208+
209+
```
210+
191211
## New Features 🚀
192212

213+
### Proper offline support
214+
215+
In v3, React Query has always fired off queries and mutations, but then taken the assumption that if you want to retry it, you need to be connected to the internet. This has led to several confusing situations:
216+
217+
- You are offline and mount a query - it goes to loading state, the request fails, and it stays in loading state until you go online again, even though it is not really fetching.
218+
- Similarly, if you are offline and have retries turned off, your query will just fire and fail, and the query goes to error state.
219+
- You are offline and want to fire off a query that doesn't necessarily need network connection (because you _can_ use React Query for something other than data fetching), but it fails for some other reason. That query will now be paused until you go online again.
220+
- Window focus refetching didn't do anything at all if you were offline.
221+
222+
With v4, React Query introduces a new `networkMode` to tackle all these issues. Please read the dedicated page about the new [Network mode](../guides/network-mode) for more information.
223+
193224
### Mutation Cache Garbage Collection
194225

195226
Mutations can now also be garbage collected automatically, just like queries. The default `cacheTime` for mutations is also set to 5 minutes.
227+
228+
### Tracked Queries per default
229+
230+
React Query defaults to "tracking" query properties, which should give you a nice boost in render optimization. The feature has existed since [v3.6.0](https://github.com/tannerlinsley/react-query/releases/tag/v3.6.0) and has now become the default behavior with v4.

docs/src/pages/guides/network-mode.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
id: network-mode
3+
title: Network Mode
4+
---
5+
6+
React Query provides three different network modes to distinguish how [Queries](./queries) and [Mutations](./mutations) should behave if you have no network connection. This mode can be set for each Query / Mutation individually, or globally via the query / mutation defaults.
7+
8+
Since React Query is most often used for data fetching in combination with data fetching libraries, the default network mode is [online](#network-mode-online).
9+
10+
## Network Mode: online
11+
12+
In this mode, Queries and Mutations will not fire unless you have network connection. This is the default mode. If a fetch is initiated for a query, it will always stay in the `state` (`loading`, `idle`, `error`, `success`) it is in if the fetch cannot be made because there is no network connection. However, a `fetchStatus` is exposed additionally. This can be either:
13+
14+
- `fetching`: The `queryFn` is really executing - a request is in-flight.
15+
- `paused`: The query is not executing - it is `paused` until you have connection again
16+
- `idle`: The query is not fetching and not paused
17+
18+
The flags `isFetching` and `isPaused` are derived from this state and exposed for convenience.
19+
20+
> Keep in mind that it might not be enough to check for `loading` state to show a loading spinner. Queries can be in `state: 'loading'`, but `fetchStatus: 'paused'` if they are mounting for the first time, and you have no network connection.
21+
22+
If a query runs because you are online, but you go offline while the fetch is still happening, React Query will also pause the retry mechanism. Paused queries will then continue to run once you re-gain network connection. This is independent of `refetchOnReconnect` (which also defaults to `true` in this mode), because it is not a `refetch`, but rather a `continue`. If the query has been [cancelled](./query-cancellation) in the meantime, it will not continue.
23+
24+
## Network Mode: always
25+
26+
In this mode, React Query will always fetch and ignore the online / offline state. This is likely the mode you want to choose if you use React Query in an environment where you don't need an active network connection for your Queries to work - e.g. if you just read from `AsyncStorage`, or if you just want to return `Promise.resolve(5)` from your `queryFn`.
27+
28+
- Queries will never be `paused` because you have no network connection.
29+
- Retries will also not pause - your Query will go to `error` state if it fails.
30+
- `refetchOnReconnect` defaults to `false` in this mode, because reconnecting to the network is not a good indicator anymore that stale queries should be refetched. You can still turn it on if you want.
31+
32+
## Network Mode: offlineFirst
33+
34+
This mode is the middle ground between the first two options, where React Query will run the `queryFn` once, but then pause retries. This is very handy if you have a serviceWorker that intercepts a request for caching like in an [offline-first PWA](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Offline_Service_workers), or if you use HTTP caching via the [Cache-Control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#the_cache-control_header).
35+
36+
In those situations, the first fetch might succeed because it comes from an offline storage / cache. However, if there is a cache miss, the network request will go out and fail, in which case this mode behaves like an `online` query - pausing retries.
37+
38+
## Devtools
39+
40+
The [React Query Devtools](../devtools) will show Queries in a `paused` state if they would be fetching, but there is no network connection. There is also a toggle button to _Mock offline behavior_. Please note that this button will _not_ actually mess with your network connection (you can do that in the browser devtools), but it will set the [OnlineManager](../reference/onlineManager) in an offline state.
41+
42+
## Signature
43+
44+
- `networkMode: 'online' | 'always' | 'offlineFirst`
45+
- optional
46+
- defaults to `'online'`

docs/src/pages/reference/useMutation.md

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const {
1919
} = useMutation(mutationFn, {
2020
cacheTime,
2121
mutationKey,
22+
networkMode,
2223
onError,
2324
onMutate,
2425
onSettled,
@@ -46,6 +47,10 @@ mutate(variables, {
4647
- `mutationKey: string`
4748
- Optional
4849
- A mutation key can be set to inherit defaults set with `queryClient.setMutationDefaults` or to identify the mutation in the devtools.
50+
- `networkMode: 'online' | 'always' | 'offlineFirst`
51+
- optional
52+
- defaults to `'online'`
53+
- see [Network Mode](../guides/network-mode) for more information.
4954
- `onMutate: (variables: TVariables) => Promise<TContext | void> | TContext | void`
5055
- Optional
5156
- This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive
@@ -98,6 +103,9 @@ mutate(variables, {
98103
- `error` if the last mutation attempt resulted in an error.
99104
- `success` if the last mutation attempt was successful.
100105
- `isIdle`, `isLoading`, `isSuccess`, `isError`: boolean variables derived from `status`
106+
- `isPaused: boolean`
107+
- will be `true` if the mutation has been `paused`
108+
- see [Network Mode](../guides/network-mode) for more information.
101109
- `data: undefined | unknown`
102110
- Defaults to `undefined`
103111
- The last successfully resolved data for the query.

docs/src/pages/reference/useQuery.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
isFetched,
1515
isFetchedAfterMount,
1616
isFetching,
17+
isPaused,
1718
isIdle,
1819
isLoading,
1920
isLoadingError,
@@ -26,11 +27,13 @@ const {
2627
refetch,
2728
remove,
2829
status,
30+
fetchStatus,
2931
} = useQuery(queryKey, queryFn?, {
3032
cacheTime,
3133
enabled,
34+
networkMode,
3235
initialData,
33-
initialDataUpdatedAt
36+
initialDataUpdatedAt,
3437
isDataEqual,
3538
keepPreviousData,
3639
meta,
@@ -78,6 +81,10 @@ const result = useQuery({
7881
- `enabled: boolean`
7982
- Set this to `false` to disable this query from automatically running.
8083
- Can be used for [Dependent Queries](../guides/dependent-queries).
84+
- `networkMode: 'online' | 'always' | 'offlineFirst`
85+
- optional
86+
- defaults to `'online'`
87+
- see [Network Mode](../guides/network-mode) for more information.
8188
- `retry: boolean | number | (failureCount: number, error: TError) => boolean`
8289
- If `false`, failed queries will not retry by default.
8390
- If `true`, failed queries will retry infinitely.
@@ -218,9 +225,15 @@ const result = useQuery({
218225
- `isFetchedAfterMount: boolean`
219226
- Will be `true` if the query has been fetched after the component mounted.
220227
- This property can be used to not show any previously cached data.
228+
- `fetchStatus: FetchStatus`
229+
- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `loading` as well as background refetches.
230+
- `paused`: The query wanted to fetch, but has been `paused`
231+
- `idle`: The query is not fetching
232+
- see [Network Mode](../guides/network-mode) for more information.
221233
- `isFetching: boolean`
222-
- Is `true` whenever a request is in-flight, which includes initial `loading` as well as background refetches.
223-
- Will be `true` if the query is currently fetching, including background fetching.
234+
- A derived boolean from the `fetchStatus` variable above, provided for convenience.
235+
- `isPaused: boolean`
236+
- A derived boolean from the `fetchStatus` variable above, provided for convenience.
224237
- `isRefetching: boolean`
225238
- Is `true` whenever a background refetch is in-flight, which _does not_ include initial `loading`
226239
- Is the same as `isFetching && !isLoading`

src/core/infiniteQueryObserver.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ export class InfiniteQueryObserver<
133133
hasNextPage: hasNextPage(options, state.data?.pages),
134134
hasPreviousPage: hasPreviousPage(options, state.data?.pages),
135135
isFetchingNextPage:
136-
state.isFetching && state.fetchMeta?.fetchMore?.direction === 'forward',
136+
state.fetchStatus === 'fetching' &&
137+
state.fetchMeta?.fetchMore?.direction === 'forward',
137138
isFetchingPreviousPage:
138-
state.isFetching &&
139+
state.fetchStatus === 'fetching' &&
139140
state.fetchMeta?.fetchMore?.direction === 'backward',
140141
}
141142
}

src/core/mutation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ export class Mutation<
277277
},
278278
retry: this.options.retry ?? 0,
279279
retryDelay: this.options.retryDelay,
280+
networkMode: this.options.networkMode,
280281
})
281282

282283
return this.retryer.promise

src/core/queriesObserver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class QueriesObserver extends Subscribable<QueriesObserverListener> {
7474
): QueryObserverMatch[] {
7575
const prevObservers = this.observers
7676
const defaultedQueryOptions = queries.map(options =>
77-
this.client.defaultQueryObserverOptions(options)
77+
this.client.defaultQueryOptions(options)
7878
)
7979

8080
const matchingObservers: QueryObserverMatch[] = defaultedQueryOptions.flatMap(
@@ -125,7 +125,7 @@ export class QueriesObserver extends Subscribable<QueriesObserverListener> {
125125
}
126126

127127
private getObserver(options: QueryObserverOptions): QueryObserver {
128-
const defaultedOptions = this.client.defaultQueryObserverOptions(options)
128+
const defaultedOptions = this.client.defaultQueryOptions(options)
129129
const currentObserver = this.observersMap[defaultedOptions.queryHash!]
130130
return currentObserver ?? new QueryObserver(this.client, defaultedOptions)
131131
}

src/core/query.ts

+18-21
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import type {
1515
QueryMeta,
1616
CancelOptions,
1717
SetDataOptions,
18+
FetchStatus,
1819
} from './types'
1920
import type { QueryCache } from './queryCache'
2021
import type { QueryObserver } from './queryObserver'
2122
import { notifyManager } from './notifyManager'
2223
import { getLogger } from './logger'
23-
import { Retryer, isCancelledError } from './retryer'
24+
import { Retryer, isCancelledError, canFetch } from './retryer'
2425
import { Removable } from './removable'
2526

2627
// TYPES
@@ -49,10 +50,9 @@ export interface QueryState<TData = unknown, TError = unknown> {
4950
errorUpdatedAt: number
5051
fetchFailureCount: number
5152
fetchMeta: any
52-
isFetching: boolean
5353
isInvalidated: boolean
54-
isPaused: boolean
5554
status: QueryStatus
55+
fetchStatus: FetchStatus
5656
}
5757

5858
export interface FetchContext<
@@ -198,12 +198,10 @@ export class Query<
198198

199199
protected optionalRemove() {
200200
if (!this.observers.length) {
201-
if (this.state.isFetching) {
202-
if (this.hadObservers) {
203-
this.scheduleGc()
204-
}
205-
} else {
201+
if (this.state.fetchStatus === 'idle') {
206202
this.cache.remove(this)
203+
} else if (this.hadObservers) {
204+
this.scheduleGc()
207205
}
208206
}
209207
}
@@ -265,7 +263,7 @@ export class Query<
265263
}
266264

267265
isFetching(): boolean {
268-
return this.state.isFetching
266+
return this.state.fetchStatus === 'fetching'
269267
}
270268

271269
isStale(): boolean {
@@ -358,7 +356,7 @@ export class Query<
358356
options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>,
359357
fetchOptions?: FetchOptions
360358
): Promise<TData> {
361-
if (this.state.isFetching) {
359+
if (this.state.fetchStatus !== 'idle') {
362360
if (this.state.dataUpdatedAt && fetchOptions?.cancelRefetch) {
363361
// Silently cancel current fetch if the user wants to cancel refetches
364362
this.cancel({ silent: true })
@@ -441,7 +439,7 @@ export class Query<
441439

442440
// Set to fetching state if not already in it
443441
if (
444-
!this.state.isFetching ||
442+
this.state.fetchStatus === 'idle' ||
445443
this.state.fetchMeta !== context.fetchOptions?.meta
446444
) {
447445
this.dispatch({ type: 'fetch', meta: context.fetchOptions?.meta })
@@ -495,6 +493,7 @@ export class Query<
495493
},
496494
retry: context.options.retry,
497495
retryDelay: context.options.retryDelay,
496+
networkMode: context.options.networkMode,
498497
})
499498

500499
this.promise = this.retryer.promise
@@ -541,10 +540,9 @@ export class Query<
541540
errorUpdatedAt: 0,
542541
fetchFailureCount: 0,
543542
fetchMeta: null,
544-
isFetching: false,
545543
isInvalidated: false,
546-
isPaused: false,
547544
status: hasData ? 'success' : 'idle',
545+
fetchStatus: 'idle',
548546
}
549547
}
550548

@@ -561,20 +559,21 @@ export class Query<
561559
case 'pause':
562560
return {
563561
...state,
564-
isPaused: true,
562+
fetchStatus: 'paused',
565563
}
566564
case 'continue':
567565
return {
568566
...state,
569-
isPaused: false,
567+
fetchStatus: 'fetching',
570568
}
571569
case 'fetch':
572570
return {
573571
...state,
574572
fetchFailureCount: 0,
575573
fetchMeta: action.meta ?? null,
576-
isFetching: true,
577-
isPaused: false,
574+
fetchStatus: canFetch(this.options.networkMode)
575+
? 'fetching'
576+
: 'paused',
578577
status: !state.dataUpdatedAt ? 'loading' : state.status,
579578
}
580579
case 'success':
@@ -585,9 +584,8 @@ export class Query<
585584
dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
586585
error: null,
587586
fetchFailureCount: 0,
588-
isFetching: false,
589587
isInvalidated: false,
590-
isPaused: false,
588+
fetchStatus: 'idle',
591589
status: 'success',
592590
}
593591
case 'error':
@@ -603,8 +601,7 @@ export class Query<
603601
errorUpdateCount: state.errorUpdateCount + 1,
604602
errorUpdatedAt: Date.now(),
605603
fetchFailureCount: state.fetchFailureCount + 1,
606-
isFetching: false,
607-
isPaused: false,
604+
fetchStatus: 'idle',
608605
status: 'error',
609606
}
610607
case 'invalidate':

0 commit comments

Comments
 (0)