Closed LikeDreamwalker closed 3 months ago
Also, for my scenario, if I am trying to use render
or portal
from react-dome
to attach a component to the app, I actually can't use the useRouter
even if it comes from next-intl
's createSharedPathnamesNavigation
, which will bring me in:
Really need some help now.
im not great with this but maybe import useRouter from next/navigation instead and see if that works
Description
This issue is weird, and I don't know if next-intl is supposed to do this. For a next.js project with next-intl, normally, we should do this by the official documentation:
And for some reasons, I am trying to import and use the
useRouter
fromnext/router
, so codes become like this:I will receive an issue like:
I can understand that
next-intl
needs some support fromnext/router
and maybe modified it, but I didn't notice this from the official documentation, and this issue took me some time to figure out. And for my scenario, I am trying to develop a public component, which needsnext/router
, and I import it directly. Now I need to build a setup for this component to make it okay with both the original next.js project and thenext-intl
project.Verifications
Mandatory reproduction URL
https://github.com/LikeDreamwalker/nextjs-mui-zustand-template/tree/dev-next-router-issue
Reproduction description
I make the demo in my public repo, so you can try it as:
pnpm i
pnpm run dev
src\components\MenuList\index.tsx
, you can see the comment and by using the differentuseRouter
to reproduce the issueAlso you can do this:
next-intl
Expected behaviour
useRouter
fromnext/router
shouldn't have an errornext-intl
can make a more preceding notificationnext-intl
can make a more clear alert in the official document (and please forgive me if I missed it)