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'
22import type { Context } from 'react'
33import type { Action , AnyAction , Store } from 'redux'
44import type { Subscription } from '../utils/Subscription'
@@ -15,13 +15,17 @@ export interface ReactReduxContextValue<
1515 noopCheck : CheckFrequency
1616}
1717
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+
1921function getContext ( ) {
22+ let realContext = gT [ ContextKey ]
2023 if ( ! realContext ) {
2124 realContext = createContext < ReactReduxContextValue > ( null as any )
2225 if ( process . env . NODE_ENV !== 'production' ) {
2326 realContext . displayName = 'ReactRedux'
2427 }
28+ gT [ ContextKey ] = realContext
2529 }
2630 return realContext
2731}
You can’t perform that action at this time.
0 commit comments