forked from secomind/OOBE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
44 lines (36 loc) · 1.06 KB
/
index.tsx
File metadata and controls
44 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { Root } from "react-dom/client";
import { createRoot } from "react-dom/client";
import { IntlProvider } from "react-intl";
import en from "./i18n/langs-compiled/en.json";
import it from "./i18n/langs-compiled/it.json";
import App, { AppProps } from "./App";
const messages = { en, it };
type UserPreferences = {
language: "en" | "it";
};
type Settings = {
themeUrl: string;
userPreferences: UserPreferences;
};
let root: Root | null = null;
const AppLifecycle = {
mount: (container: ShadowRoot, appProps: AppProps, settings: Settings) => {
const { themeUrl, userPreferences } = settings;
const { language } = userPreferences;
root = createRoot(container);
root.render(
<>
<link href={themeUrl} type="text/css" rel="stylesheet" />
<IntlProvider
messages={messages[language]}
locale={language}
defaultLocale="en"
>
<App {...appProps} />
</IntlProvider>
</>,
);
},
unmount: (container: ShadowRoot) => root?.unmount(),
};
export default AppLifecycle;