You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error occurs in my LocalizationProvider component.
import React, { useEffect } from 'react';
import { i18n } from '@lingui/core';
import { I18nProvider } from '@lingui/react';
import { messages as messagesJa } from '../locales/ja/messages';
import AppLanguage from '../i18n/AppLanguage';
import useLocalStoragePreferences from '../queries/auth/useLocalStoragePreferences';
/**
* https://lingui.js.org/guides/dynamic-loading-catalogs.html
* We do a dynamic import of just the catalog that we need
* @param locale any locale string
*/
async function dynamicActivate(locale: string) {
if (locale === AppLanguage.Japanese) {
const { messages } = await import('../locales/ja/messages.js');
i18n.load(locale, messages);
i18n.activate(locale);
} else if (locale === AppLanguage.English) {
const { messages } = await import('../locales/en/messages.js');
i18n.load(locale, messages);
i18n.activate(locale);
}
}
interface MyProps {
children: JSX.Element;
}
// Loading the English language separately saves about ~30 kb in the app bundle size.
i18n.load({
ja: messagesJa,
});
const LocalizationProvider: React.FC<MyProps> = ({ children }: MyProps) => {
// Running in a useEffect() hook results in this message for the first render:
// I18nProvider did not render.
// A call to i18n.activate still needs to happen or
// forceRenderOnLocaleChange must be set to false.
// useEffect(() => {
// i18n.activate('ja');
// }, []);
// Default to Japanese.
i18n.activate(AppLanguage.Japanese);
const localStoragePreferences = useLocalStoragePreferences();
useEffect(() => {
const { language } = localStoragePreferences;
if (language && i18n.locale !== language) {
dynamicActivate(language);
}
}, [localStoragePreferences]);
return <I18nProvider i18n={i18n}>{children}</I18nProvider>;
};
export default LocalizationProvider;
Expected behavior
I expect no warning to be emitted.
The text was updated successfully, but these errors were encountered:
Describe the bug
After updating to next-7 from next-5 (skipped next-6 due to #1596), I'm getting the following warning:
To Reproduce
The error occurs in my LocalizationProvider component.
Expected behavior
I expect no warning to be emitted.
The text was updated successfully, but these errors were encountered: