Link component reloads the whole page in the new version(9)
See original GitHub issueBug report
Describe the bug
The Link component reloads the whole page after migrating to NextJS 9, and using the new dynamic routing APIs.
This is how i used the Link component before
<Link
href={{
pathname: "/news",
query: { id: props.id }
}}
prefetch
>
<a className={classes.link}>{props.title}</a>
</Link>
and this is after migration:
<Link href={`/news/${props.id}`}>
<a className={classes.link}>{props.title}</a>
</Link>
and this the page folder:
pages
news
[id].js
this is the content of [id].js
import React from "react";
import SingleNews from "../../components/SingleNews";
const News = ({ id }) => {
return <SingleNews id={id} />;
};
News.getInitialProps = async ({ query }) => {
return { id: query.id };
};
export default News;
Expected behavior
For the Links to transition smoothly to other pages
System information
- OS: Kubuntu
- Browser: chrome
- Version of Next.js: 9
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
IE 9 - Link (React Router) - Link click reload entire page
I've 16.8.4 version of React, 4.3.1 version for (React Router & React Router Dom) and 4.0.1 version of Redux. The actual result is...
Read more >Angular: Reload/Refresh a Component or Entire ...
An Angular tutorial on how to reload/refresh a single component or the entire application and reuse the logic across multiple components.
Read more >Nextjs causing hard refresh when i click in the Link #9382
I have an app react using CRA, and I am trying to turn it into an SSR app using next. So, since there...
Read more >Force reload Next.js pages two ways! - YouTube
In this video I show you how to Force reload Next.js pages using the useRouter hook or in places that you ...
Read more >Using React Router to avoid Page Reload | Django ... - YouTube
here is the github link for code:https://github.com/sauravsharmaz/My-Cart-Django-ReactVideo By - saurav.sharma.zz45@gmail.com Saurav ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @yassinebridi, this is not a bug.
href
in<Link>
refers to the path inside your./pages
directory -https://github.com/zeit/next.js#dynamic-routingTry this
thanks @delbaoliveira, that worked perfectly.