File tree 1 file changed +8
-5
lines changed 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
- import { createContext , version as ReactVersion } from 'react'
1
+ import { createContext } 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,17 +15,20 @@ export interface ReactReduxContextValue<
15
15
noopCheck : CheckFrequency
16
16
}
17
17
18
- const ContextKey = Symbol . for ( `react-redux-context-${ ReactVersion } ` )
19
- const gT = globalThis as { [ ContextKey ] ?: Context < ReactReduxContextValue > }
18
+ const ContextKey = Symbol . for ( `react-redux-context` )
19
+ const gT = globalThis as {
20
+ [ ContextKey ] ?: Map < typeof createContext , Context < ReactReduxContextValue > >
21
+ }
20
22
21
23
function getContext ( ) {
22
- let realContext = gT [ ContextKey ]
24
+ const contextMap = ( gT [ ContextKey ] ??= new Map ( ) )
25
+ let realContext = contextMap . get ( createContext )
23
26
if ( ! realContext ) {
24
27
realContext = createContext < ReactReduxContextValue > ( null as any )
25
28
if ( process . env . NODE_ENV !== 'production' ) {
26
29
realContext . displayName = 'ReactRedux'
27
30
}
28
- gT [ ContextKey ] = realContext
31
+ contextMap . set ( createContext , realContext )
29
32
}
30
33
return realContext
31
34
}
You can’t perform that action at this time.
0 commit comments