-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
Trans component only works if i18n is explicitly passed in #47
Comments
@isaachinman i guess it's not related to next-i18next - but not yet sure why this happens...there is some wild context providing/consuming by the nature of an optional Provider (each NamespaceConsumer acts as a Provider too - so might be somewhere it gets messy with updating: overall using the Will need to create a pure react sample and try to reproduce. Currently i'm already on my xmas holidays but will try to get on this asap. |
@jamuhl I can try to reproduce with just React as well. This is a server side exception, though. Do you think there might be multiple i18n instances somehow, and that's the root of the problem? Enjoy your holidays first and foremost! |
just tried to reproduce here: https://github.com/i18next/react-i18next/blob/master/example/react/src/index.js#L14 with changing to using the provider and removing use reactI18nextModule...but no luck...like you said might be a serverside thing only... |
I've reverted the tree-walking approach with v0.11.0, but am still seeing this bug. Here's the specific exception:
The stack trace points to:
So it seems this |
Interestingly, but
|
@kachkaev that can be...not easy to get es modules, commonjs and typescript under one hat. |
Where does the issue lie? Inside |
in typescript 😂 - no somewhere in i18next, react-i18next - but sadly no typescript user ever could tell me what to do to get it right for them without breaking the world for non typescript users... |
@jamuhl Did you see the broken branch I created? It's not working in the |
@isaachinman yes...but could that not reproduce on non serverside -> so not really sure where it comes from?!?? as v10 will completely remove using context i guess this won't be a problem there...might currently be safer to |
You mean when initialising the |
sample: https://github.com/i18next/react-i18next/blob/master/example/react/src/i18n.js#L15 it's a set/get (https://github.com/i18next/react-i18next/blob/master/src/context.js#L26)...only drawback you can't have multiple instances in one app |
Yes, but how do we handle |
It seems like doing |
Yes, but how do we handle initialLanguage and initialI18nStore? Hm...that is done in the Provider - my guess is as it only gets missed somewhere deeper in the tree out of unknown reason doing both is safe |
Okay. When does v10 land, do you think? |
fully depends on https://reactjs.org/blog/2018/11/27/react-16-roadmap.html 16.(7) |
Alright well, I've got no idea what the problem is here. I am 95% sure it's a context bug that is within the For users that want to use |
Using a version of I shared similar thoughts in #42 – |
Following reports in #33 and #40, I've investigated the use of
Trans
innext-i18next
projects, despite our codebase not touching it - the component comes directly fromreact-i18next
.It does appear there's a genuine issue here, and it appears it's related to context.
To explain very concisely:
I created a branch called trans-comp-broken-context to demonstrate the problem. Feel free to do a
git checkout
.This is despite the
Trans
component definitely being inside aI18NextProvider
component, which is successfully providing context for ourwithNamespaces
HOC (justNamespacesConsumer
under the hood):Not sure what's different about the
Trans
component, and also not sure if this is the fault ofnext-i18next
or not.@jamuhl Sorry to bother, but do you possibly have an idea?
The text was updated successfully, but these errors were encountered: