Next.js Discord

Discord Forum

Link component does not redirect

Unanswered
Schweizer Laufhund posted this in #help-forum
Open in Discord
Avatar
Schweizer LaufhundOP
Something odd is happening, I'm assuming it's because of the way Next renders things.

(Using app router). So I have this component with a <Link> and when I click it it's supposed to redirect me to a dynamically generated route. However, when I have
use client
in my dynamic route file clicking the link component does nothing, only when I add remove "use client" does the page automatically send me to the right url. The reason why my dynamically generated route is a client component is because i want have
onClick
enabled
Image

3 Replies

Avatar
Schweizer LaufhundOP
Ok I think i found the reason why, fetching the data in my client component was causing it
Avatar
Schweizer LaufhundOP
does anyone know how to fetch data in a dynamic route when its a client component?
Avatar
Brown bear
My best guess is you need to make the fetch call inside of a useEffect hook.