Skip to content

Commit 27cf109

Browse files
committed
Fix invalidateTags
1 parent 7c3129c commit 27cf109

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ 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) {
75-
if (Object.keys(subscriptionSubState).length === 0) {
76-
mwApi.dispatch(
77-
removeQueryResult({
78-
queryCacheKey: queryCacheKey as QueryCacheKey,
79-
})
80-
)
81-
} else if (querySubState.status !== QueryStatus.uninitialized) {
82-
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
83-
} else {
84-
}
73+
const subscriptionSubState = state.subscriptions[queryCacheKey] || {}
74+
75+
if (!querySubState) continue
76+
77+
if (Object.keys(subscriptionSubState).length === 0) {
78+
mwApi.dispatch(
79+
removeQueryResult({
80+
queryCacheKey: queryCacheKey as QueryCacheKey,
81+
})
82+
)
83+
} else if (querySubState.status !== QueryStatus.uninitialized) {
84+
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
8585
}
8686
}
8787
})

0 commit comments

Comments
 (0)