-
-
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
useTranslation is the cause of the rerender component #1636
Comments
using an i18next backend like i18next-http-backend will for sure rerender, because the i18next init call is asynchronous and also loading the specific namespace is asynchronous. |
Thanks. I'm not using This is the
I've also tried commenting out the EDIT |
How does your index file look like? Are you using the |
Yes, using
|
Then it's normal... like said here: it only happens during development: #1599 (comment) I have no idea how to prevent that. |
I see. You are right. Tested with a built app and it doesn't happen. |
🐛 Bug Report
When using the
useTranslation
hook the component is re-rendered even if the translation is not used and when there is no change to the language.I have found a similar reported issue here: #1291 but it was closed with the explanation that there is not issue.
To rule out a situation that it is something in my app that I'm missing, I've created a new react app without anything in it and reproduced the issue.
To Reproduce
npx create-react-app my-app
console.log("App component loading");
in App component inside the App function.const { t, i18n } = useTranslation();
is added"App component loading"
is printed twice in the console. When removed it is ok.Expected behavior
Component should not re-render by the
useTranslation
hook.Your Environment
The text was updated successfully, but these errors were encountered: