Hello everybody,
I tried to implement this package into my setup which is heavily inspired by this repo https://github.com/atherosai/next-react-graphql-apollo .
But even by exactly following the instructions from the readme I always get an error message on the server side, which reads as follows:
react-i18next:: You will need pass in an i18next instance by using initReactI18next
Nevertheless the code works and translations are applied. Additionally I get a console error on page load, with the content:
Warning: Expected server HTML to contain a matching
Does anyone maybe have an idea, what could cause the issues?
Thanks in advance!
Best regards, Patrick
I might as well try to create a repo that reproduces the issues and share it with you later today.
Yes, please do. Can't really help without a reproducible repo, as there are way too many factors in play.
@patsa we had the same error message when we added react-i18next as direct dependency in our package.json and imported their useTranslation hook for example.
In that case we had to something like this:
import { initReactI18next } from 'react-i18next';
const NextI18NextInstance = new NextI18Next({
...
use: [initReactI18next]
}
Need to mention that we are on Typescript and we ran into follow up issues with error messages that i18n.languages would be undefined.
But since this lib exports that hook itself we rolled back and haven't those issues anymore, obviously.
@isaachinman
I published a repository with an example implementation based on the system I'm using for my real app too.
https://github.com/patsa/react-next-i18next-example-application
I temporarily added you as a collaborator. Feel free to check the code out.
Currently next-i18next isn't working at all (with the same setup as in my original code where it works).
A couple of points to hopefully help you in the future:
That aside, the error is straightforward:
Error while running `getDataFromTree` TypeError: Cannot read property 'i18n' of undefined
If you do some basic Googling and/or searching of issues in this repo and Apollo, you'll quickly see this is due to tree traversal and most likely reflects invalid context as your original comment also indicates.
Good luck to you - this is not something that next-i18next is willing/able to help debug as it involves the use of several different packages. That said, there are many users who have combined Apollo with next-i18next. Perhaps try on StackOverflow or Spectrum.
@patsa we had the same error message when we added
react-i18nextas direct dependency in ourpackage.jsonand imported theiruseTranslationhook for example.In that case we had to something like this:
import { initReactI18next } from 'react-i18next'; const NextI18NextInstance = new NextI18Next({ ... use: [initReactI18next] }Need to mention that we are on Typescript and we ran into follow up issues with error messages that
i18n.languageswould be undefined.But since this lib exports that hook itself we rolled back and haven't those issues anymore, obviously.
Thanks, that fixed my issue. I'm wondering why this is needed as I didn't need to do this before I convert to typescript
Most helpful comment
@patsa we had the same error message when we added
react-i18nextas direct dependency in ourpackage.jsonand imported theiruseTranslationhook for example.In that case we had to something like this:
Need to mention that we are on Typescript and we ran into follow up issues with error messages that
i18n.languageswould be undefined.But since this lib exports that hook itself we rolled back and haven't those issues anymore, obviously.