Skip to content

Commit a7246a6

Browse files
committed
Fix infinite query preselector loading state
1 parent b602b65 commit a7246a6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/toolkit/src/query/react/buildHooks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,10 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
13401340
// isFetching = true any time a request is in flight
13411341
const isFetching = currentState.isLoading
13421342
// isLoading = true only when loading while no data is present yet (initial load with no data in the cache)
1343-
const isLoading = !hasData && isFetching
1343+
const isLoading =
1344+
(!lastResult || lastResult.isLoading || lastResult.isUninitialized) &&
1345+
!hasData &&
1346+
isFetching
13441347
// isSuccess = true when data is present
13451348
const isSuccess = currentState.isSuccess || (isFetching && hasData)
13461349

0 commit comments

Comments
 (0)