Skip to content

Commit

Permalink
refactor: simplify condition
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed Dec 10, 2024
1 parent 2040a6c commit 28b6fcc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/query-core/src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit 28b6fcc

Please sign in to comment.