Closed varmil closed 3 weeks ago
// routing.ts export const { Link, getPathname, redirect, usePathname, useRouter } = createLocalizedPathnamesNavigation({ locales: routing.locales, pathnames: { '/': '/' } }) --- // component.tsx <Link href={`/${group}/channels/${basicInfo.id}`} prefetch={true}> ... </Link>
// routing.ts export const { Link, getPathname, redirect, usePathname, useRouter } = createNavigation(routing) --- // component.tsx <Link href={`/${group}/channels/${basicInfo.id}`} prefetch={true}> ... </Link>
The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`
Hypothesis after reading the code
When using createLocalizedPathnamesNavigation, the locale is ultimately set here. The same is true for the Client.
createLocalizedPathnamesNavigation
const finalLocale = locale || (await getLocale());
On the other hand, when using createNavigation, it appears that isChangingLocale is checked here without calculating finalLocale.
createNavigation
isChangingLocale
As a result, locale in createNavigation is probably undefined and isChangingLocale is always true.
locale
This is the version in which the bug was confirmed to occur.
"next-intl": "^3.23.3", "next": "15.0.1",
https://github.com/varmil/noxi/pull/626/files#diff-ee810f949a204706e7360b0af570aea479f0efb7103a3abaaceb8c0acfb8c9bdL5-R5
Steps to reproduce:
npm run dev
./web
Since I don't use a locale prop, we expect prefetch to proceed without error.
Oh you're absolutely right, thanks for the bug report and the great analysis! Should have a fix ready soon.
Description
OK
NG
Error Message
Hypothesis after code reading
Hypothesis after reading the code
When using
createLocalizedPathnamesNavigation
, the locale is ultimately set here. The same is true for the Client.On the other hand, when using
createNavigation
, it appears thatisChangingLocale
is checked here without calculating finalLocale.As a result,
locale
increateNavigation
is probably undefined andisChangingLocale
is always true.versions
This is the version in which the bug was confirmed to occur.
Verifications
Mandatory reproduction URL
https://github.com/varmil/noxi/pull/626/files#diff-ee810f949a204706e7360b0af570aea479f0efb7103a3abaaceb8c0acfb8c9bdL5-R5
Reproduction description
Steps to reproduce:
npm run dev
in./web
dir. Go browser.Expected behaviour
Since I don't use a locale prop, we expect prefetch to proceed without error.