diff --git a/src/state/internal/createQueryStore.ts b/src/state/internal/createQueryStore.ts index 91032e9208a..9e48d80d7e0 100644 --- a/src/state/internal/createQueryStore.ts +++ b/src/state/internal/createQueryStore.ts @@ -238,6 +238,13 @@ export type QueryStoreConfig { + if (disableAutoRefetching) return; const effectiveStaleTime = options?.staleTime ?? staleTime; if (effectiveStaleTime <= 0 || effectiveStaleTime === Infinity) return; + if (activeRefetchTimeout) { clearTimeout(activeRefetchTimeout); activeRefetchTimeout = null; @@ -824,7 +834,7 @@ export function createQueryStore< set(state => ({ ...state, queryKey: currentQueryKey })); - if (subscriptionCount === 1 && enabled) { + if ((subscriptionCount === 1 || disableAutoRefetching) && enabled) { if (isStale() || !get().queryCache[currentQueryKey]?.lastFetchedAt) { fetch(currentParams); } else {