Context.js 843 B

12345678910111213141516171819202122232425262728
  1. import * as React from 'react';
  2. const ContextKey = Symbol.for(`react-redux-context`);
  3. const gT = typeof globalThis !== "undefined" ? globalThis :
  4. /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
  5. {};
  6. function getContext() {
  7. var _gT$ContextKey;
  8. if (!React.createContext) return {};
  9. const contextMap = (_gT$ContextKey = gT[ContextKey]) != null ? _gT$ContextKey : gT[ContextKey] = new Map();
  10. let realContext = contextMap.get(React.createContext);
  11. if (!realContext) {
  12. realContext = React.createContext(null);
  13. if (process.env.NODE_ENV !== 'production') {
  14. realContext.displayName = 'ReactRedux';
  15. }
  16. contextMap.set(React.createContext, realContext);
  17. }
  18. return realContext;
  19. }
  20. export const ReactReduxContext = /*#__PURE__*/getContext();
  21. export default ReactReduxContext;