Skip to content

Commit f56d0ae

Browse files
committed
Tweak infinite query forced check
1 parent 844c93d commit f56d0ae

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/toolkit/src/query/core/buildThunks.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,10 @@ export function buildThunks<
552552
const blankData = { pages: [], pageParams: [] }
553553
const cachedData = getState()[reducerPath].queries[arg.queryCacheKey]
554554
?.data as InfiniteData<unknown, unknown> | undefined
555+
// Don't want to use `isForcedQuery` here, because that
556+
// includes `refetchOnMountOrArgChange`.
555557
const existingData = (
556-
isForcedQuery(arg, getState()) || !cachedData ? blankData : cachedData
558+
arg.forceRefetch || !cachedData ? blankData : cachedData
557559
) as InfiniteData<unknown, unknown>
558560

559561
// If the thunk specified a direction and we do have at least one page,

packages/toolkit/src/query/tests/buildHooks.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ describe('hooks tests', () => {
18131813
)
18141814
})
18151815

1816-
test.only.each([
1816+
test.each([
18171817
['no refetch', pokemonApi],
18181818
['with refetch', pokemonApiWithRefetch],
18191819
])(`useInfiniteQuery %s`, async (_, pokemonApi) => {

0 commit comments

Comments
 (0)