Skip to content

Link component reloads the whole page in the new version(9) #8085

@yassinebridi

Description

@yassinebridi

Bug 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions