mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Remove defaultMessages from the production build.
Don't run the application before active locale will be loaded
This commit is contained in:
@@ -5,12 +5,14 @@ import i18n from 'app/services/i18n';
|
||||
import { RootState } from 'app/reducers';
|
||||
|
||||
const IntlProvider: ComponentType = ({ children }) => {
|
||||
const [intl, setIntl] = useState<IntlShape>(i18n.getIntl());
|
||||
const [intl, setIntl] = useState<IntlShape>();
|
||||
const locale = useSelector(({ i18n: i18nState }: RootState) => i18nState.locale);
|
||||
|
||||
useEffect(() => {
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
// disable async modules loading in tests
|
||||
setIntl(i18n.getIntl());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,6 +21,11 @@ const IntlProvider: ComponentType = ({ children }) => {
|
||||
})();
|
||||
}, [locale]);
|
||||
|
||||
// don't run the application until locale bundle will be loaded
|
||||
if (!intl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <RawIntlProvider value={intl}>{children}</RawIntlProvider>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user