Skip to content

Commit

Permalink
fix: improve loading state in i18n provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gciotola committed Dec 19, 2024
1 parent ad44ccd commit 7beac90
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/app-elements/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export {
createRoute,
createTypedRoute,
GenericPageNotFound,
LoadingPage,
Routes,
type GetParams,
type PageProps,
Expand Down
3 changes: 2 additions & 1 deletion packages/app-elements/src/providers/I18NProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LoadingPage } from '#ui/composite/Routes/Routes'
import i18n, { type i18n as I18nInstance } from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import resourcesToBackend from 'i18next-resources-to-backend'
Expand Down Expand Up @@ -55,7 +56,7 @@ export const I18NProvider: React.FC<I18NProviderProps> = ({
i18nInstance == null ||
(i18nInstance != null && !i18nInstance.isInitialized)
) {
return <div>Loading i18n</div>
return <LoadingPage />
}

return <I18nextProvider i18n={i18nInstance}>{children}</I18nextProvider>
Expand Down
6 changes: 5 additions & 1 deletion packages/app-elements/src/ui/composite/Routes/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ function Route({
)
}

function LoadingPage({ overlay = false }: { overlay?: boolean }): JSX.Element {
export function LoadingPage({
overlay = false
}: {
overlay?: boolean
}): JSX.Element {
const {
settings: { mode }
} = useTokenProvider()
Expand Down
7 changes: 6 additions & 1 deletion packages/app-elements/src/ui/composite/Routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export { GenericPageNotFound, Routes, type PageProps } from './Routes'
export {
GenericPageNotFound,
LoadingPage,
Routes,
type PageProps
} from './Routes'
export {
createRoute,
createTypedRoute,
Expand Down

0 comments on commit 7beac90

Please sign in to comment.