Skip to content

Commit 19d725b

Browse files
committed
remove unneccessary batch
1 parent 76e570e commit 19d725b

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

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

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -633,38 +633,35 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
633633
}, [subscriptionRemoved])
634634

635635
usePossiblyImmediateEffect((): void | undefined => {
636-
batch(() => {
637-
const lastPromise = promiseRef.current
638-
if (
639-
typeof process !== 'undefined' &&
640-
process.env.NODE_ENV === 'removeMeOnCompilation'
641-
) {
642-
// this is only present to enforce the rule of hooks to keep `isSubscribed` in the dependency array
643-
console.log(subscriptionRemoved)
644-
}
636+
const lastPromise = promiseRef.current
637+
if (
638+
typeof process !== 'undefined' &&
639+
process.env.NODE_ENV === 'removeMeOnCompilation'
640+
) {
641+
// this is only present to enforce the rule of hooks to keep `isSubscribed` in the dependency array
642+
console.log(subscriptionRemoved)
643+
}
645644

646-
if (stableArg === skipToken) {
647-
lastPromise?.unsubscribe()
648-
promiseRef.current = undefined
649-
return
650-
}
645+
if (stableArg === skipToken) {
646+
lastPromise?.unsubscribe()
647+
promiseRef.current = undefined
648+
return
649+
}
651650

652-
const lastSubscriptionOptions =
653-
promiseRef.current?.subscriptionOptions
651+
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions
654652

655-
if (!lastPromise || lastPromise.arg !== stableArg) {
656-
lastPromise?.unsubscribe()
657-
const promise = dispatch(
658-
initiate(stableArg, {
659-
subscriptionOptions: stableSubscriptionOptions,
660-
forceRefetch: refetchOnMountOrArgChange,
661-
})
662-
)
663-
promiseRef.current = promise
664-
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
665-
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions)
666-
}
667-
})
653+
if (!lastPromise || lastPromise.arg !== stableArg) {
654+
lastPromise?.unsubscribe()
655+
const promise = dispatch(
656+
initiate(stableArg, {
657+
subscriptionOptions: stableSubscriptionOptions,
658+
forceRefetch: refetchOnMountOrArgChange,
659+
})
660+
)
661+
promiseRef.current = promise
662+
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
663+
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions)
664+
}
668665
}, [
669666
dispatch,
670667
initiate,

0 commit comments

Comments
 (0)