Closed slowwriter closed 11 months ago
I had to remove this to support Static Rendering. We could add it again but that means users will have to wrap components using useChangeLocale
in a Suspense
boundary, which reduces the usefulness of Static Rendering: https://nextjs.org/docs/app/api-reference/functions/use-search-params#static-rendering
Is it possible to make this optional? Suspense wrapping only required for people who want to maintain searchParams?
You'll have to wrap with Suspense
if you want Static Rendering, but unfortunately, we can't call hooks conditionally.
What's your use case?
Maybe the best solution is to create an additional language change hook with useSearchParams
inside to keep full static rendering usability in the current useChangeLocale
hook.
My use case: I mainly have dynamic routes. I keep the entire application state in the url using: https://www.npmjs.com/package/next-usequerystate
I've published next-international@1.1.0-rc.2
that introduces a new preserveSearchParams
option in useChangeLocale
.
You'll manually have to wrap the component using this hook in a Suspense
boundary to prevent opting out the entire page from Static Rendering. See the documentation here: https://next-international-git-feat-110-quiibz.vercel.app/docs/app-get-change-locale#preserving-search-params
It will be released officially in #205
Storing searchParams after changing the language by useChangeLocale stopped working. I implemented all the changes from the release 1.0.0 description.