-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-i18next:: You will need to pass in an i18next instance by using initReactI18next #1594
Comments
This is not a reproducible example (best would be a minimal expo example that works also in browser)... these are just code snippets... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@Namangaraaz I just got the same error. This issue arose when I started using the Slice API in my app. Disable slice Api and try. (my app is based Gatsbyjs) |
This definitely comes up since #1588 We have quite a complicated setup with 2 instances, one of them used within components injected into an iframe. I can try to reproduce it in a sandbox. |
Also having issues with Gatsby and gatsby-plugin-react-i18next. It works with 12.0.0 but 12.1.0 and up crash because it's not finding the i18n object from the context (I18nextProvider is used in the Gatsby plugin automatically). |
A minimal reproducible example would help to investigate... |
@adrai https://github.com/coderanger/react-i18next-crash-repro here you go :-) It's a stock |
If you downgrade react-i18next to 12.0.0 it will work. |
@coderanger can you try with v12.1.3 ? |
Digging a little more to confirm that the fix doesn't just result in silencing the error while still failing to load translations, will update shortly. |
Confirmed, I changed that bit of code to be |
Okay that works, though I'm a bit confused why it does :D The gatsby plugin is just re-exporting all the symbols from react-i18next under the hood. Is this something weird with npm's nested dependencies and React not considering the two copies of react-i18next to be the same? |
maybe @jimmyn can help with this question? |
The gatsby plugin does (correctly) list react-i18next as a peer dep so there aren't actually even two copies of it, and yet your fix definitely works. JavaScript confusion abounds :D |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
https://github.com/sgardnervio/contextless_reacti18n I’ve encountered this warning as well and it shows in the UI as the key being displayed and not the value. The use case is loading a component from a separate package into a UI app that has an I want to be clear in stating I’m not interested in loading a different |
tried also with v12.1.4 |
@adrai thanks for taking a look so quickly. I see that the react-component-lib works.. but it is also using a different as for it working for your and not me I guess I'd have to ask if you re-ran the with 12.1.4 in use locally I still encounter the same issue where the May I inquire as to why the move away from |
React.useContext() has not been removed! We just introduced a Trans component version that does not use the react context for server side environments, like Next.js 13 app dir. Line 23 in 11bfe43
but there is also a Trans component without that usage: https://github.com/i18next/react-i18next/blob/master/src/TransWithoutContext.js Honestly I don't know why it worked with v12.0.0... imo it should not have worked either... Seems like yarn is using 2 different react-i18next instances (one in app and one in components). I'm not a yarn user, so if you know of anything we could do to help, let me know. I have no idea, sorry. |
@adrai I just wanted to loop back around and let you know I've found a solution.. while I would prefer to not have to implement this solution for each component it seems to satisfy my needs of using the essentially I'm using the HoC concept and passing in to the component the you can if your curious see this in my latest code in the reproducible example. Using the provider with v12.1.4 still doesn't work but I wasn't a big fan of that approach anyways. I'm still curious on why imported components could access the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hello guys, I'm also facing this error in production only. Any lead on what might the root cause of this ? I am using backend plugin to get the my translations. Everything is so smooth on FE but once i build my react app and use the bundle in the BE I'm seeing this error. The error goes away if i reload the page few time but comes back. |
@Travel24Seven A minimal reproducible example may help. |
@adrai we are using this library in our private company codebase. I am not sure how to get the code on the public domain. facing the issue with bundling the react-i18next as the code work fines in the front end individual server but gets this error when bundled. BTW thanks for such a early reply. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@sgardnervio / @adrai Any idea how to fix this without having to wrap all components with an HOC? The weirdest is that it worked before this refactor... I am using webpack5, and weirder is that the latest version of i18next work for webpack4 but not on webpack5.... I am not sure how to create a reproducible sandbox because I would need a published npm package (mine is proprietary) + webpack5 config + main app, I am not sure how to put this all into a sandbox-like... But, if I could get at least keywords/ideas on where to look? I don't have any fancy processing on my node_modules with webpack5... ( I mostly use an emitted version of CRA's project) And basically: I also saw reports on this GH of this issue |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Any update here ? |
@crow7m Using latest react-i18next version worked for me |
Thank you @gabycperezdias |
In order to initialise it, import init file to index.js file on root level. ` AppRegistry.registerComponent(appName, () => App) Now the error disappears and working well with translations. import { useTranslation } from 'react-i18next' const { t } = useTranslation() t('key') |
Thanks @padabala, I forgot to initialise in index.js |
🐛 Bug Report
getting this issue in my react native project.

Using the same versions in another react native project both has same react native version. But issue persist in one not another.
MY code
i18next file-----
import i18next from 'i18next';
import english from './english.json';
import { initReactI18next } from 'react-i18next';
i18next.use(initReactI18next).init({
compatibilityJSON: 'v3',
lng: 'en',
resources: {
en: english,
},
react: {
useSuspense: false,
},
});
export default i18next;
--using manner----
const { t, i18n } = useTranslation();
----{t('ReviewingYou')}
Your Environment
"react-i18next": "^12.0.0",
"react-native-translation": "^1.1.0",
"react": "18.1.0",
react native version 0.70.6
The text was updated successfully, but these errors were encountered: