question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

withTranslation with {wait:true}

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
imdadulcommented, Apr 7, 2020

not for fun

Oh! I thought it was for fun 😃 @jamuhl

I understand the point.

1reaction
jamuhlcommented, Apr 7, 2020

forcing components to handle that in order to avoid that log

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found