File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ function useSelectorWithStoreAndSubscription(
14
14
contextSub
15
15
) {
16
16
const [ reduxState , forceRender ] = useState ( store . getState ( ) )
17
+ const latestReduxState = useRef ( )
17
18
18
19
const subscription = useMemo ( ( ) => new Subscription ( store , contextSub ) , [
19
20
store ,
@@ -31,7 +32,7 @@ function useSelectorWithStoreAndSubscription(
31
32
selector !== latestSelector . current ||
32
33
latestSubscriptionCallbackError . current
33
34
) {
34
- selectedState = selector ( reduxState )
35
+ selectedState = selector ( latestReduxState . current || reduxState )
35
36
} else {
36
37
selectedState = latestSelectedState . current
37
38
}
@@ -58,6 +59,7 @@ function useSelectorWithStoreAndSubscription(
58
59
const newSelectedState = latestSelector . current ( newReduxState )
59
60
60
61
if ( equalityFn ( newSelectedState , latestSelectedState . current ) ) {
62
+ latestReduxState . current = newReduxState
61
63
return
62
64
}
63
65
@@ -69,7 +71,7 @@ function useSelectorWithStoreAndSubscription(
69
71
// changed
70
72
latestSubscriptionCallbackError . current = err
71
73
}
72
-
74
+ latestReduxState . current = undefined
73
75
forceRender ( newReduxState )
74
76
}
75
77
You can’t perform that action at this time.
0 commit comments