You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
715 B

import { createContext, version as ReactVersion } from 'react';
const ContextKey = Symbol.for(`react-redux-context-${ReactVersion}`);
const gT = globalThis;
function getContext() {
let realContext = gT[ContextKey];
if (!realContext) {
realContext = createContext(null);
if (process.env.NODE_ENV !== 'production') {
realContext.displayName = 'ReactRedux';
}
gT[ContextKey] = realContext;
}
return realContext;
}
export const ReactReduxContext = /*#__PURE__*/new Proxy({}, /*#__PURE__*/new Proxy({}, {
get(_, handler) {
const target = getContext(); // @ts-ignore
return (_target, ...args) => Reflect[handler](target, ...args);
}
}));
export default ReactReduxContext;