@tanstack/react-query 4.35.3 → 4.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3263,18 +3263,23 @@
|
|
|
3263
3263
|
mutationKey: dehydratedMutation.mutationKey
|
|
3264
3264
|
}, dehydratedMutation.state);
|
|
3265
3265
|
});
|
|
3266
|
-
queries.forEach(
|
|
3266
|
+
queries.forEach(({
|
|
3267
|
+
queryKey,
|
|
3268
|
+
state,
|
|
3269
|
+
queryHash
|
|
3270
|
+
}) => {
|
|
3267
3271
|
var _options$defaultOptio2;
|
|
3268
3272
|
|
|
3269
|
-
const query = queryCache.get(
|
|
3270
|
-
// query being stuck in fetching state upon hydration
|
|
3271
|
-
|
|
3272
|
-
const dehydratedQueryState = { ...dehydratedQuery.state,
|
|
3273
|
-
fetchStatus: 'idle'
|
|
3274
|
-
}; // Do not hydrate if an existing query exists with newer data
|
|
3273
|
+
const query = queryCache.get(queryHash); // Do not hydrate if an existing query exists with newer data
|
|
3275
3274
|
|
|
3276
3275
|
if (query) {
|
|
3277
|
-
if (query.state.dataUpdatedAt <
|
|
3276
|
+
if (query.state.dataUpdatedAt < state.dataUpdatedAt) {
|
|
3277
|
+
// omit fetchStatus from dehydrated state
|
|
3278
|
+
// so that query stays in its current fetchStatus
|
|
3279
|
+
const {
|
|
3280
|
+
fetchStatus: _ignored,
|
|
3281
|
+
...dehydratedQueryState
|
|
3282
|
+
} = state;
|
|
3278
3283
|
query.setState(dehydratedQueryState);
|
|
3279
3284
|
}
|
|
3280
3285
|
|
|
@@ -3283,9 +3288,13 @@
|
|
|
3283
3288
|
|
|
3284
3289
|
|
|
3285
3290
|
queryCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio2 = options.defaultOptions) == null ? void 0 : _options$defaultOptio2.queries),
|
|
3286
|
-
queryKey
|
|
3287
|
-
queryHash
|
|
3288
|
-
},
|
|
3291
|
+
queryKey,
|
|
3292
|
+
queryHash
|
|
3293
|
+
}, // Reset fetch status to idle to avoid
|
|
3294
|
+
// query being stuck in fetching state upon hydration
|
|
3295
|
+
{ ...state,
|
|
3296
|
+
fetchStatus: 'idle'
|
|
3297
|
+
});
|
|
3289
3298
|
});
|
|
3290
3299
|
}
|
|
3291
3300
|
|