mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
* build: enable consistent type imports eslint rule * change to warn * fix the warning in example and excalidraw-app * fix packages * enable type annotations and throw error for the rule
28 lines
804 B
TypeScript
28 lines
804 B
TypeScript
import React, { useEffect, useState } from "react";
|
|
|
|
import { LoadingMessage } from "./LoadingMessage";
|
|
import type { Language } from "../i18n";
|
|
import { defaultLang, languages, setLanguage } from "../i18n";
|
|
import type { Theme } from "../element/types";
|
|
|
|
interface Props {
|
|
langCode: Language["code"];
|
|
children: React.ReactElement;
|
|
theme?: Theme;
|
|
}
|
|
|
|
export const InitializeApp = (props: Props) => {
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const updateLang = async () => {
|
|
await setLanguage(currentLang);
|
|
setLoading(false);
|
|
};
|
|
const currentLang =
|
|
languages.find((lang) => lang.code === props.langCode) || defaultLang;
|
|
updateLang();
|
|
}, [props.langCode]);
|
|
|
|
return loading ? <LoadingMessage theme={props.theme} /> : props.children;
|
|
};
|