You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useLocale will always return the locale path parameter in client components even though NextIntlClientProvider is configured with a hard-coded locale.
I cannot find anything related to this behaviour in the documentation so this should probably be documented and/or add an option to useLocale to retrieve the locale from the provider and not the path parameters for client components.
Open up the /_next/info page and view the resulting locales.
Open up the /en/info page and view the resulting locales.
Remove the notFound(); call in src/app/[locale]/layout.tsx.
Open up the /_next/info page and view the resulting locales.
Expected behaviour
The universal "useLocale" hook should return the expected locale configured in the provider in client components.
All displayed locales should be "en" in client components.
This ensures that components can be re-used in 404:s from _next/* paths.
The text was updated successfully, but these errors were encountered:
Description
useLocale
will always return the locale path parameter in client components even thoughNextIntlClientProvider
is configured with a hard-coded locale.I cannot find anything related to this behaviour in the documentation so this should probably be documented and/or add an option to useLocale to retrieve the locale from the provider and not the path parameters for client components.
next-intl/packages/next-intl/src/react-client/useLocale.tsx
Lines 9 to 18 in 4369c76
Mandatory reproduction URL (CodeSandbox or GitHub repository)
https://codesandbox.io/p/devbox/next-intl-bug-template-app-forked-w4q7qq
Reproduction description
/_next/info
page and view the resulting locales./en/info
page and view the resulting locales.notFound();
call insrc/app/[locale]/layout.tsx
./_next/info
page and view the resulting locales.Expected behaviour
The universal "useLocale" hook should return the expected locale configured in the provider in client components.
All displayed locales should be "en" in client components.
This ensures that components can be re-used in 404:s from _next/* paths.
The text was updated successfully, but these errors were encountered: