Consistent warning that "I18nProvider did not render ..."
See original GitHub issueWhen using I18nProvider
from @lingui/react
in a Next app, I got a consistent console warning every-time warning that
I18nProvider did not render. A call to i18n.activate still needs to happen or forceRenderOnLocaleChange must be set to false.
We load the locale async in an useEffect
like
const { locale = 'en' } = useRouter();
useEffect(() => {
async function load(locale: string) {
const { messages } = await import(
`../translations/locales/${locale}/messages.po`
);
i18n.load(locale, messages);
i18n.activate(locale);
}
load(locale);
}, [locale]);
meaning activate will always get called, though not in the initial server side render output. Is this warning an indication of an issue or problem? If so how can I fix it? Setting forceRenderOnLocaleChange
to false
is not an option as I cannot see a reason why I would not want children
to rerender if the user changes the language.
Or is this async locale load simply not the way to do it?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:17 (1 by maintainers)
Top Results From Across the Web
API Reference - React (@lingui/react) - LinguiJS
Default rendering component can be set using defaultComponent prop in <I18nProvider>. The main use case for this is rendering translations in <Text> ...
Read more >Cannot update a component while rendering a different ...
My error message was: Warning: Cannot update a component ( ForwardRef(BaseNavigationContainer) ) while rendering a different component ...
Read more >Server Side Rendering – React Aria
Server side rendering, or SSR, is the process of rendering components to HTML on ... SSRProvider will ensure the ids are consistent when...
Read more >Measuring non-rendered elements in React with Portals
The need of measuring non-rendered elements is not that common. ... In the example above, we defined the rowHeight as a constant as...
Read more >a context consumer was rendered with multiple children, or a ...
Warning : A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran into the same issue after applying the dynamic loading method. It seems that it is triggered by the
<I18nProvider>
component when it is first rendered, before the useEffect hook runs.Maintainers, please correct me if I’m wrong. As far as I can see things still work as expected. The warning doesn’t seem to do any harm, but it is annoying and it is costing developers time because it looks like something that needs to be fixed.
As a workaround, to get rid of the warning, I added two lines to the I18n loader helper, immediately after the call to
i18n.loadLocaleData()
:This activates the default locale with an empty set of messages, so at least a “dummy locale” is active when
<I18nProvider>
is first rendered.Same question as @tommhuth and same setup. Language files are loaded in async/await and only then activate()/load() is called. It seems to be working anyway but quite annoying if it doesn’t really indicate a real issue. It should be possible though according to https://lingui.js.org/guides/dynamic-loading-catalogs.html#final-i18n-loader-helper