@equinor/mad-core
Version:
Core library for the Mobile App Delivery team
38 lines (35 loc) • 1.32 kB
JavaScript
import {
ServiceMessageProvider
} from "./chunk-PQGICZTY.js";
import {
CoreNavigatorTypeProvider
} from "./chunk-PP74MP4O.js";
import {
EnvironmentProvider
} from "./chunk-ZSXJVU5B.js";
// src/utils/MadCoreProviders.tsx
import React, { useLayoutEffect } from "react";
import {
AppInsightsInitializer,
disableInsights
} from "@equinor/mad-insights";
import { ToastEmitter } from "@equinor/mad-toast";
var AppInsightsSlot = ({ config }) => {
if (!config) return null;
return /* @__PURE__ */ React.createElement(AppInsightsInitializer, { config }, null);
};
var MadCoreProviders = ({
config,
type,
children
}) => {
const insightsConfig = config.applicationInsights;
const hasInsightsConfig = !!insightsConfig;
useLayoutEffect(() => {
if (!hasInsightsConfig) disableInsights();
}, [hasInsightsConfig]);
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(AppInsightsSlot, { config: insightsConfig }), /* @__PURE__ */ React.createElement(CoreNavigatorTypeProvider, { type }, /* @__PURE__ */ React.createElement(EnvironmentProvider, null, /* @__PURE__ */ React.createElement(ServiceMessageProvider, null, children, type === "native-stack" && /* @__PURE__ */ React.createElement(ToastEmitter, null)))));
};
export {
MadCoreProviders
};