configcat-react
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
20 lines (19 loc) • 732 B
JavaScript
import React from "react";
/** @remarks Map key: provider id normalized to lower case. */
var ConfigCatContextRegistry = new Map();
function registryKeyFor(providerId) {
return providerId ? providerId.toLowerCase() : "";
}
export function ensureConfigCatContext(providerId) {
var key = registryKeyFor(providerId);
var context = ConfigCatContextRegistry.get(key);
if (!context) {
context = React.createContext(void 0);
context.displayName = "ConfigCatContext" + (providerId ? "_" + providerId : "");
ConfigCatContextRegistry.set(key, context);
}
return context;
}
export function getConfigCatContext(providerId) {
return ConfigCatContextRegistry.get(registryKeyFor(providerId));
}