Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

Having trouble with NextJs use Router in react js

Having trouble with NextJs use Router in react js

The issue is occurring because you're using a react hook on the top level. Instead of this, you should be using the hook inside your React Functional component.

Something like this:

 import { useRouter } from 'next/router'

function ActiveLink({ href }) {
  const router = useRouter()

  return (
    <a href={href}>
      This will redirect
    </a>
  )
}

export default ActiveLink

14 0

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online