Skip to content

Commit

Permalink
doc: add a section on fallback ssg pages in the readme (#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmeziere committed Dec 5, 2023
1 parent a66f01c commit 343872a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export const getStaticProps = async ({ locale }) => ({

When using on server-side generated pages with [`getStaticPaths`](https://nextjs.org/docs/pages/api-reference/functions/get-static-paths) and [`fallback: true`](https://nextjs.org/docs/pages/api-reference/functions/get-static-paths#fallback-true) or [`fallback: 'blocking'`](https://nextjs.org/docs/pages/api-reference/functions/get-static-paths#fallback-blocking), the default setup indicated above will cause the app to be unmounted and remounted on every load, causing various adverse consequences like calling every `useEffect(() => {...}, [])` hook twice and slight performance degradation.

This is due to the fact that, for those pages, Next.js does a first renders with empty `serverSideProps` and then a second render with the `serverSideProps`, that include the `next-i18next` translations. With the default setup, the `i18n` instance is initially `undefined` when `serverSideProps` is `empty`, causing the unmount-remount.
This is due to the fact that, for those pages, Next.js does a first render with empty `serverSideProps` and then a second render with the `serverSideProps` that include the `next-i18next` translations. With the default setup, the `i18n` instance is initially `undefined` when `serverSideProps` is `empty`, causing the unmount-remount.

To mitigate this issue, you can do the following:

Expand Down

0 comments on commit 343872a

Please sign in to comment.