Skip to content
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

Translations not reactively updating in some React components #2229

Closed
jshimko opened this issue May 9, 2017 · 3 comments
Closed

Translations not reactively updating in some React components #2229

jshimko opened this issue May 9, 2017 · 3 comments
Assignees
Labels
bug For issues that describe a defect or regression in the released software

Comments

@jshimko
Copy link
Contributor

jshimko commented May 9, 2017

Since the translated label props that get passed into the React components are just an i18n key that doesn't change, the components aren't re-rendering the new language.

For example, I switched to Spanish, reloaded the page, then switched to Chinese. This is what I get on the PDP.

image

If you take a look in the React devtools, you can see why the re-render didn't happen...

basic_reaction_product

So we need to do something to invalidate the props when the language changes. Perhaps it makes sense to have the current language loaded in React context and then create a helper that watches for the change and forces a re-render on any i18n items. This would also be a great use case for Redux, but that's a lot more steps at this point (and probably not practical until the entire tree is React).

@jshimko
Copy link
Contributor Author

jshimko commented May 9, 2017

Or maybe...

https://github.com/i18next/react-i18next

That's actually using React context to pass things down the tree, so it's pretty much exactly what I was saying above.

@aaronjudd aaronjudd added the bug For issues that describe a defect or regression in the released software label May 9, 2017
@aaronjudd aaronjudd added this to the PDP UI Components milestone May 9, 2017
@mikemurray
Copy link
Member

Might need to use the <TranslationProvider /> and the <Translation /> component. or someday, maybe redux.

@kieckhafer
Copy link
Member

@jshimko I believe this is fixed in PR #2283, in this commit, which wraps the entire app inside the TranslationProvider. Once 1.2 is merged you should see the fix in master.

Closing for now, can re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For issues that describe a defect or regression in the released software
Projects
None yet
Development

No branches or pull requests

5 participants