SSG - Infinite render loop - Too many re-renders. React limits the number of renders to prevent an infinite loop #12444
-
I am migrating my SSR-based app into an SSG/SSR (hybrid) app. In the process, I'm encountering an error where I get See Steps to reproduce
You'll get a Development stack trace
DebugWould you have any advice on how to debug that? I have no clue as to what's the cause of the infinite loop. It seems to be client-side based. I also happens when using query parameters, such as:
It may be related to experimental rewrites/redirects: experimental: {
redirects() {
const redirects = [
{
// Redirect root link with trailing slash to non-trailing slash, avoids 404 - See https://github.com/zeit/next.js/discussions/10651#discussioncomment-8270
source: '/:locale/',
destination: '/:locale',
permanent: process.env.APP_STAGE !== 'development', // Do not use permanent redirect locally to avoid browser caching when working on it
},
{
// Redirect link with trailing slash to non-trailing slash (any depth), avoids 404 - See https://github.com/zeit/next.js/discussions/10651#discussioncomment-8270
source: '/:locale/:path*/',
destination: '/:locale/:path*',
permanent: process.env.APP_STAGE !== 'development', // Do not use permanent redirect locally to avoid browser caching when working on it
},
];
if (process.env.APP_STAGE === 'development') {
console.info('Using experimental redirects:', redirects);
}
return redirects;
},
rewrites() {
const rewrites = [
{
// XXX Doesn't work locally (maybe because of rewrites), but works online
source: '/',
destination: '/api/autoRedirectToLocalisedPage',
},
{
// TODO Build "source" based on active locales (instead of hardcoded)
source: `/:locale((?!${allowedLocales.join('|')})[^/]+)(.*)`, // source: '/:locale((?!fr-FR|fr|en-US|en)[^/]+)(.*)',
destination: '/api/autoRedirectToLocalisedPage',
},
];
if (process.env.APP_STAGE === 'development') {
console.info('Using experimental rewrites:', rewrites);
}
return rewrites;
},
}, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This has been fixed. See UnlyEd/next-right-now@331c9d0 The reason was related to how i18next works internally, fixed by using a singleton to avoid reinitizalization between page rendering (CSR) |
Beta Was this translation helpful? Give feedback.
This has been fixed. See UnlyEd/next-right-now@331c9d0
The reason was related to how i18next works internally, fixed by using a singleton to avoid reinitizalization between page rendering (CSR)