
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com> Co-authored-by: dwelle <luzar.david@gmail.com>
36 lines
746 B
TypeScript
36 lines
746 B
TypeScript
import React from "react";
|
|
|
|
import { LoadingMessage } from "./LoadingMessage";
|
|
import {
|
|
defaultLang,
|
|
Language,
|
|
languages,
|
|
setLanguageFirstTime,
|
|
} from "../i18n";
|
|
|
|
interface Props {
|
|
langCode: Language["code"];
|
|
}
|
|
interface State {
|
|
isLoading: boolean;
|
|
}
|
|
export class InitializeApp extends React.Component<Props, State> {
|
|
public state: { isLoading: boolean } = {
|
|
isLoading: true,
|
|
};
|
|
|
|
async componentDidMount() {
|
|
const currentLang =
|
|
languages.find((lang) => lang.code === this.props.langCode) ||
|
|
defaultLang;
|
|
await setLanguageFirstTime(currentLang);
|
|
this.setState({
|
|
isLoading: false,
|
|
});
|
|
}
|
|
|
|
public render() {
|
|
return this.state.isLoading ? <LoadingMessage /> : this.props.children;
|
|
}
|
|
}
|