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
hey,
there is a bug ( or maybe expected behavior ) when using useLocale()
it makes all my fetch requests with tag param not cached,
but only the first fetch in that page will be cached with the associated tag
exportdefaultasyncfunctionHome({searchParams: { test },}: {searchParams: {test: string};}){constres=awaitfetch("https://randomuser.me/api/",{next: {tags: ["tag1"]},});constjson=awaitres.json();// will be cachedconstres2=awaitfetch("https://randomuser.me/api/?new=true",{next: {tags: ["tag2"]},});constjson2=awaitres2.json();// will not be cachedreturn;}
one solution is to use unstable_setRequestLocale(locale) before useLocale()
exportdefaultasyncfunctionLocaleLayout({
children,params: { locale },}: Props){// this line will make fetch tag worksunstable_setRequestLocale(locale);constdir=useTextDirection(locale);// removing this line will make fetch tag worksreturn(<htmllang={locale}dir={dir}><head><title>next-intl-bug-repro-app-router</title></head><body>{children}</body></html>);}
is this expected behavior ?
Verifications
I've verified that the problem I'm experiencing isn't covered in the docs.
I've searched for similar, existing issues on GitHub and Stack Overflow.
Thanks for the report, this is a duplicate of #612.
As you've noticed, static rendering avoids this issue (with hopefully #663 being the general solution in this area). Alternatively, you can configure the fetchCache accordingly.
Description
hey,
there is a bug ( or maybe expected behavior ) when using useLocale()
it makes all my fetch requests with tag param not cached,
but only the first fetch in that page will be cached with the associated tag
one solution is to use unstable_setRequestLocale(locale) before useLocale()
is this expected behavior ?
Verifications
Mandatory reproduction URL
https://github.com/islamBelabbes/next-intl-bug-repro-app-router
Reproduction description
Steps to reproduce:
Expected behaviour
fetch with next :{tags} option caches both requests
or no request at all since I think useLocale() uses cookie() or header()
The text was updated successfully, but these errors were encountered: