@tanstack/react-query
Advanced tools
Comparing version
@@ -14,6 +14,5 @@ "use client"; | ||
const client = useQueryClient(queryClient); | ||
const [hydrationQueue, setHydrationQueue] = React.useState(); | ||
const optionsRef = React.useRef(options); | ||
optionsRef.current = options; | ||
React.useMemo(() => { | ||
const hydrationQueue = React.useMemo(() => { | ||
if (state) { | ||
@@ -33,6 +32,3 @@ if (typeof state !== "object") { | ||
const hydrationIsNewer = dehydratedQuery.state.dataUpdatedAt > existingQuery.state.dataUpdatedAt || dehydratedQuery.promise && existingQuery.state.status !== "pending" && existingQuery.state.fetchStatus !== "fetching" && dehydratedQuery.dehydratedAt !== void 0 && dehydratedQuery.dehydratedAt > existingQuery.state.dataUpdatedAt; | ||
const queryAlreadyQueued = hydrationQueue == null ? void 0 : hydrationQueue.find( | ||
(query) => query.queryHash === dehydratedQuery.queryHash | ||
); | ||
if (hydrationIsNewer && (!queryAlreadyQueued || dehydratedQuery.state.dataUpdatedAt > queryAlreadyQueued.state.dataUpdatedAt)) { | ||
if (hydrationIsNewer) { | ||
existingQueries.push(dehydratedQuery); | ||
@@ -46,12 +42,10 @@ } | ||
if (existingQueries.length > 0) { | ||
setHydrationQueue( | ||
(prev) => prev ? [...prev, ...existingQueries] : existingQueries | ||
); | ||
return existingQueries; | ||
} | ||
} | ||
}, [client, hydrationQueue, state]); | ||
return void 0; | ||
}, [client, state]); | ||
React.useEffect(() => { | ||
if (hydrationQueue) { | ||
hydrate(client, { queries: hydrationQueue }, optionsRef.current); | ||
setHydrationQueue(void 0); | ||
} | ||
@@ -58,0 +52,0 @@ }, [client, hydrationQueue]); |
@@ -14,6 +14,5 @@ "use client"; | ||
const client = useQueryClient(queryClient); | ||
const [hydrationQueue, setHydrationQueue] = React.useState(); | ||
const optionsRef = React.useRef(options); | ||
optionsRef.current = options; | ||
React.useMemo(() => { | ||
const hydrationQueue = React.useMemo(() => { | ||
if (state) { | ||
@@ -33,6 +32,3 @@ if (typeof state !== "object") { | ||
const hydrationIsNewer = dehydratedQuery.state.dataUpdatedAt > existingQuery.state.dataUpdatedAt || dehydratedQuery.promise && existingQuery.state.status !== "pending" && existingQuery.state.fetchStatus !== "fetching" && dehydratedQuery.dehydratedAt !== void 0 && dehydratedQuery.dehydratedAt > existingQuery.state.dataUpdatedAt; | ||
const queryAlreadyQueued = hydrationQueue?.find( | ||
(query) => query.queryHash === dehydratedQuery.queryHash | ||
); | ||
if (hydrationIsNewer && (!queryAlreadyQueued || dehydratedQuery.state.dataUpdatedAt > queryAlreadyQueued.state.dataUpdatedAt)) { | ||
if (hydrationIsNewer) { | ||
existingQueries.push(dehydratedQuery); | ||
@@ -46,12 +42,10 @@ } | ||
if (existingQueries.length > 0) { | ||
setHydrationQueue( | ||
(prev) => prev ? [...prev, ...existingQueries] : existingQueries | ||
); | ||
return existingQueries; | ||
} | ||
} | ||
}, [client, hydrationQueue, state]); | ||
return void 0; | ||
}, [client, state]); | ||
React.useEffect(() => { | ||
if (hydrationQueue) { | ||
hydrate(client, { queries: hydrationQueue }, optionsRef.current); | ||
setHydrationQueue(void 0); | ||
} | ||
@@ -58,0 +52,0 @@ }, [client, hydrationQueue]); |
{ | ||
"name": "@tanstack/react-query", | ||
"version": "5.80.2", | ||
"version": "5.80.3", | ||
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React", | ||
@@ -59,4 +59,4 @@ "author": "tannerlinsley", | ||
"react-error-boundary": "^4.1.2", | ||
"@tanstack/query-persist-client-core": "5.80.2", | ||
"@tanstack/query-test-utils": "0.0.0" | ||
"@tanstack/query-test-utils": "0.0.0", | ||
"@tanstack/query-persist-client-core": "5.80.2" | ||
}, | ||
@@ -63,0 +63,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
711768
-0.53%8591
-0.38%