Page does not change after clicking next/link #14377
-
Hey guys, I've run into an issue while trying to navigate to another page using the next/link. The situation is quite straightforward. I have a page with a url parameter called slug ([slug].js). In my case the slug parameter represents different categories of products. So I have |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Just to make sure, when you're trying to navigate to <Link href="/[slug]" as="/shoes">
<a>Shoes</a>
</Link> |
Beta Was this translation helpful? Give feedback.
-
If i understand correctly, this seems to work for me:
import Link from 'next/link'
export default function SlugPage({ params }) {
return (
<div>
<Link href="/products/[slug]" as="/products/baz">
baz
</Link>
<Link href="/products/[slug]" as="/products/abc">
abc
</Link>
<pre>{JSON.stringify(params, null, 2)}</pre>
</div>
);
}
export async function getServerSideProps(context) {
return {
props: { params: context.params },
};
}
|
Beta Was this translation helpful? Give feedback.
If i understand correctly, this seems to work for me:
/pages/products/[slug]/index.js
getServerSideProps
is called each time I click a link (via an XHR request).