-
-
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
Switching between languages breaks and triggers infinite network calls when using useSuspense: true, and client-side-only translations #2095
Comments
Never use Suspense with next.js so far, seems like Next.js renders the page in the infinite loop in that case. |
Thanks for the information, @adrai! I will try that other approach. |
I also noticed that the infinite loop occurred with the same settings when switching from a page with server-rendered translation to a client-side rendered page.
AFAIK, if you want to keep some pages rendered entirely client-side, you may not be able to use the lazy-load approach as it requires calling getServerSideProps, getStaticProps (and getAllPaths if the route is dynamic). In such cases, pure client-side loading seems preferable. |
If someone knows of how that infinite loop could be prevented... (basically prevent Next.js to render that page infinitely)... feel free to contribute... it might also be a bug in Next.js? |
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. |
🐛 Bug Report
Switching between languages by using Next.js built-in internationalized routing is breaking and triggering infinite Network calls if:
{ react: { useSuspense: true } }
inside thenext-i18next.config.js
file's configuration objectbackendOptions: [{ expirationTime: 0 }]
(in development, to prevent caching translations if we are manipulating them while developing the app) inside thenext-i18next.config.js
fileTo Reproduce
A codesandbox that reproduces the error
In short, we can reproduce this bug by:
{ react: { useSuspense: true } }
andbackendOptions: [{ expirationTime: 0 }]
to thenext-i18next.config.js
objectappWithTranslation
inside the_app.tsx
fileSuspense
getStaticProps
nor agetServerSideProps
function)Grabacion.de.pantalla.2023-02-22.a.las.14.30.56.mov
Expected behavior
expirationTime
to0
in development, and not having the app break when switching between languagesYour Environment
P.S. Thank you all for your great work!
Workaround
I have realized that by simply passing that
ONE_HOUR_IN_MILISECONDS
to thebackendOptions.expirationTime
regardless of the environment, the issue is solved.We were using it so that the development translations were always the most recent ones, so as to always have the latest translation changes while developing on
localhost
since caching the translations is not something that we want/need in this environment.I wonder if, somehow, we can keep this functionality without breaking the app when switching between languages...
The text was updated successfully, but these errors were encountered: