Skip to content

Commit 3cc4a80

Browse files
committed
Remove redundant isMounted ref from connect
1 parent 720f0ba commit 3cc4a80

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/components/connect.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ function subscribeUpdates(
103103
lastWrapperProps: React.MutableRefObject<unknown>,
104104
lastChildProps: React.MutableRefObject<unknown>,
105105
renderIsScheduled: React.MutableRefObject<boolean>,
106-
isMounted: React.MutableRefObject<boolean>,
107106
childPropsFromStoreUpdate: React.MutableRefObject<unknown>,
108107
notifyNestedSubs: () => void,
109108
// forceComponentUpdateDispatch: React.Dispatch<any>,
@@ -118,7 +117,7 @@ function subscribeUpdates(
118117

119118
// We'll run this callback every time a store subscription update propagates to this component
120119
const checkForUpdates = () => {
121-
if (didUnsubscribe || !isMounted.current) {
120+
if (didUnsubscribe) {
122121
// Don't run stale listeners.
123122
// Redux doesn't guarantee unsubscriptions happen until next dispatch.
124123
return
@@ -622,18 +621,9 @@ function connect<
622621
const lastWrapperProps = useRef(wrapperProps)
623622
const childPropsFromStoreUpdate = useRef<unknown>()
624623
const renderIsScheduled = useRef(false)
625-
const isProcessingDispatch = useRef(false)
626-
const isMounted = useRef(false)
627624

628625
const latestSubscriptionCallbackError = useRef<Error>()
629626

630-
useIsomorphicLayoutEffect(() => {
631-
isMounted.current = true
632-
return () => {
633-
isMounted.current = false
634-
}
635-
}, [])
636-
637627
const actualChildPropsSelector = useMemo(() => {
638628
const selector = () => {
639629
// Tricky logic here:
@@ -677,7 +667,6 @@ function connect<
677667
lastWrapperProps,
678668
lastChildProps,
679669
renderIsScheduled,
680-
isMounted,
681670
childPropsFromStoreUpdate,
682671
notifyNestedSubs,
683672
reactListener

0 commit comments

Comments
 (0)