Yash Bathia
Yash Bathia

Reputation: 43

why next/link rendering twice? how to solve it?

I have a page inside pages so, if you go to direct URL then it will print console.log once and if you go there with then it is printing twice.

Why it is happening?

I want to perform some task once per page.

<Link route={href} href={href}>
   <a href={href}>
     page to redirect
   </a>
</Link>

I already go through with this issue https://github.com/zeit/next.js/issues/253 but still I am not clear

I am using next-routes package for <Link>

Upvotes: 0

Views: 1427

Answers (1)

kyun
kyun

Reputation: 10264

<Link to={href} href={href}>
   <a>
     page to redirect
   </a>
</Link>

remove href on <a /> and replace route to to on <Link/>

Upvotes: 1

Related Questions