diff --git a/packages/query-core/src/queryClient.ts b/packages/query-core/src/queryClient.ts index 7b4cf1dfdc..72c3a42cbf 100644 --- a/packages/query-core/src/queryClient.ts +++ b/packages/query-core/src/queryClient.ts @@ -151,16 +151,16 @@ export class QueryClient { if (cachedData === undefined) { return this.fetchQuery(options) - } else { - if ( - options.revalidateIfStale && - query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) - ) { - void this.prefetchQuery(defaultedOptions) - } + } - return Promise.resolve(cachedData) + if ( + options.revalidateIfStale && + query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) + ) { + void this.prefetchQuery(defaultedOptions) } + + return Promise.resolve(cachedData) } getQueriesData<