@awsui/components-react
Version:
On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en
29 lines • 1.4 kB
JavaScript
var _SharedReactContexts_registeredContexts;
import { __classPrivateFieldGet } from "tslib";
export class SharedReactContexts {
constructor() {
_SharedReactContexts_registeredContexts.set(this, new WeakMap());
this.createContext = (ReactInstance, contextName) => {
let contexts = __classPrivateFieldGet(this, _SharedReactContexts_registeredContexts, "f").get(ReactInstance);
if (!contexts) {
contexts = new Map();
__classPrivateFieldGet(this, _SharedReactContexts_registeredContexts, "f").set(ReactInstance, contexts);
}
let cachedContext = contexts.get(contextName);
if (!cachedContext) {
// We cannot put a default value here, because it will be shared between versions.
// Consumers of this API must apply default value on their end.
cachedContext = ReactInstance.createContext(undefined);
contexts.set(contextName, cachedContext);
}
return cachedContext;
};
}
installInternal(internalApi = {}) {
var _a;
(_a = internalApi.createContext) !== null && _a !== void 0 ? _a : (internalApi.createContext = this.createContext);
return internalApi;
}
}
_SharedReactContexts_registeredContexts = new WeakMap();
//# sourceMappingURL=shared-react-contexts.js.map