Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Nov 11, 2024
1 parent ce5fc49 commit fa916c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RecoilRoot, useSetRecoilState } from 'recoil';
import { ErrorBoundary } from '@components/ErrorBoundary';
import { Loading } from '@components/Loading';
import { ROUTES } from '@common/constants/routes.constants';
import { DEFAULT_LOCALE } from '@common/constants/i18n.constants';
import { OKAPI_CONFIG } from '@common/constants/api.constants';
import { localStorageService } from '@common/services/storage';
import { Root, Search, EditWrapper, ExternalResourcePreview } from '@views';
Expand Down Expand Up @@ -55,7 +56,7 @@ const createRouter = (basename: string) => createBrowserRouter(routes, { basenam
const Container: FC<IContainer> = ({ routePrefix = '', config }) => {
const setCustomEvents = useSetRecoilState(state.config.customEvents);
const setHasNavigationOrigin = useSetRecoilState(state.config.hasNavigationOrigin);
const cachedMessages = useRef({ en });
const cachedMessages = useRef({ [DEFAULT_LOCALE]: en });

useEffect(() => {
setCustomEvents(config?.customEvents as Record<string, string>);
Expand Down
1 change: 1 addition & 0 deletions src/common/constants/i18n.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DEFAULT_LOCALE = 'en';
3 changes: 1 addition & 2 deletions src/providers/AsyncIntlProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { FC } from 'react';
import { IntlProvider } from 'react-intl';
import { useRecoilValue } from 'recoil';
import { useLoadI18nMessages } from '@common/hooks/useLoadI18nMessages';
import { DEFAULT_LOCALE } from '@common/constants/i18n.constants';
import state from '@state';

type AsyncIntlProviderProps = {
cachedMessages: I18nMessages;
children: React.ReactNode;
};

const DEFAULT_LOCALE = 'en';

export const AsyncIntlProvider: FC<AsyncIntlProviderProps> = ({ cachedMessages, children }) => {
const locale = useRecoilValue(state.config.locale);
const { getMessages } = useLoadI18nMessages(cachedMessages, DEFAULT_LOCALE);
Expand Down

0 comments on commit fa916c4

Please sign in to comment.