-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Re-renders of memoized components on shallow route changes #1059
Comments
@isaachinman I wanted to work on this myself, but ran into some issues with
|
@skrivanos Not sure how to help, as it looks like it's dependent on your filesystem setup. Does |
Yes, everything works perfectly after unlinking. I've even md5sum:ed the files in dist/ and they match. The only difference is that after linking |
Nope, I've not run into this issue. |
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
@isaachinman Could this also explain why our dynamic namespaces are loaded on every route change? Which basically defeats the purpose oh having them since these dynamic components will flash the keys since the instance is recreated and new calls have to be made. |
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed (fix i18next#1059). * Let Next's router locale take precedence over initialLocale (fix i18next#1023). * Bump the minimum version of react-i18next.
* Memoize the i18n client and do not re-create it unless the route or locale has changed. * Let Next's router locale take precedence over initialLocale. [fix i18next#1059]
* Memoize the i18n client and do not re-create it unless the route or locale has changed. * Let Next's router locale take precedence over initialLocale. [fix i18next#1059]
* fix: partially support shallow route changes * Memoize the i18n client and do not re-create it unless the route or locale has changed. * Let Next's router locale take precedence over initialLocale. [fix #1059] * refactor: do global assignment inside useMemo * refactor: cease forwarding initialLocale from serverSideTranslations
Describe the bug
As we discussed in #983, components that utilise useTranslation are always re-rendered on shallow route changes, regardless of if they are memoized or not. This is caused by the fact that the i18n instance is re-created every time the App is rendered.
The problem has been exacerbated in the last two weeks: it now re-renders the memoized component twice on every shallow route change rather than once (compare 8.0.1 and 8.1.1). I suspect this is because of this MR being merged in react-i18next: i18next/react-i18next#1273 - which is also mentioned in #1023.
Occurs in next-i18next version
8.1.1
Steps to reproduce
Example repo: https://github.com/skrivanos/next-i18next-rerender-poc
https://next-i18next-rerender-poc.vercel.app
Expected behaviour
The memoized component should not re-render.
The text was updated successfully, but these errors were encountered: