withTranslation with {wait:true}
See original GitHub issueI am using withTranslation, i18next-xhr-backend, & inside the config.
react: {
useSuspense: false,
wait: true,
},
In my component file.
withTranslation(['wages.wageTypes'])(MyComponent)
Now, whenever my component is being rendered I am getting the message.
i18next::translator: missingKey en ns key name key name
. Either way, my component is rendering with filled translations. It’s just the log which I don’t like.
Since I am loading the namespaces asynchronously that’s why the message is showing as long as the namespace is not loaded.
What I want is that the component should wait until the translation files are loaded or not show me those messages.
Can I achieve this without using Suspense?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
withTranslation (HOC) - react-i18next documentation
The withTranslation is a classic HOC (higher order component) and gets the t function and i18n instance inside your component via props.
Read more >withTranslation HOC looks for translation in first namespace only
I was using translate HOC previously but seems that it's replaced by withTranslation now. So my simple React component after these changes ...
Read more >react-i18next | Yarn - Package Manager
Add support for keyPrefix in withTranslation 1512 ... placeholder instead of default return null in case of wait: true and not yet loaded...
Read more >Top 5 react-i18next Code Examples - Snyk
... passing setDefaults({ wait: true }); // $ExpectError - setDefaults must be called with an object setDefaults("option"); // $ExpectError - other is not...
Read more >Adding Multi-Language Support Using ReactJS - Mindbowser
withTranslation (HOC). with translation is a higher-order component that gives function and i18n instance as props of the component. For more reference follow ......
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 Free
Top 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
Oh! I thought it was for fun 😃 @jamuhl
I understand the point.
it’s there for a reason - not for fun - your application does an invalid render because it has the translations not ready…depending on your net speed this might be just a noticeable flicker - still it’s wrong.
So either use suspense, handle the ready state, use v9 with wait: true do not load translations async.