File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
- import { createContext } from 'react'
1
+ import { createContext , version as ReactVersion } from 'react'
2
2
import type { Context } from 'react'
3
3
import type { Action , AnyAction , Store } from 'redux'
4
4
import type { Subscription } from '../utils/Subscription'
@@ -15,13 +15,17 @@ export interface ReactReduxContextValue<
15
15
noopCheck : CheckFrequency
16
16
}
17
17
18
- let realContext : Context < ReactReduxContextValue > | null = null
18
+ const ContextKey = Symbol . for ( `react-redux-context-${ ReactVersion } ` )
19
+ const gT = globalThis as { [ ContextKey ] ?: Context < ReactReduxContextValue > }
20
+
19
21
function getContext ( ) {
22
+ let realContext = gT [ ContextKey ]
20
23
if ( ! realContext ) {
21
24
realContext = createContext < ReactReduxContextValue > ( null as any )
22
25
if ( process . env . NODE_ENV !== 'production' ) {
23
26
realContext . displayName = 'ReactRedux'
24
27
}
28
+ gT [ ContextKey ] = realContext
25
29
}
26
30
return realContext
27
31
}
You can’t perform that action at this time.
0 commit comments