Skip to content

Commit 1dd128b

Browse files
authored
Merge pull request #2721 from manceau-jb/bugfix/invalidate-tags
2 parents e628ed6 + ba1ba8a commit 1dd128b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/toolkit/src/query/core/buildMiddleware/invalidationByTags.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ export const build: SubMiddlewareBuilder = ({
7070
const valuesArray = Array.from(toInvalidate.values())
7171
for (const { queryCacheKey } of valuesArray) {
7272
const querySubState = state.queries[queryCacheKey]
73-
const subscriptionSubState = state.subscriptions[queryCacheKey]
74-
if (querySubState && subscriptionSubState) {
73+
const subscriptionSubState = state.subscriptions[queryCacheKey] ?? {}
74+
75+
if (querySubState) {
7576
if (Object.keys(subscriptionSubState).length === 0) {
7677
mwApi.dispatch(
7778
removeQueryResult({
@@ -80,7 +81,6 @@ export const build: SubMiddlewareBuilder = ({
8081
)
8182
} else if (querySubState.status !== QueryStatus.uninitialized) {
8283
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
83-
} else {
8484
}
8585
}
8686
}

0 commit comments

Comments
 (0)