Next.js Discord

Discord Forum

Link component does not redirect

Schweizer Laufhund posted this in #help-forum
Open in Discord
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

3 Replies

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