2

I am facing the below error while using useRouter from next/router.

TypeError: Cannot read property 'getBoundingClientRect' of null

import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'

function ActiveLink({ children, href, activeClassName }) {
  const { asPath } = useRouter()
  console.log(asPath)

  return (
    <Link href={href} />
  )
}

export default ActiveLink
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57
  • The code you posted has no reference to `getBoundingClientRect` and doesn't provide enough information about the error. Could you provide the code that's actually triggering the issue? – juliomalves Jan 23 '21 at 15:51
  • When I have added routing by using `Link`, this issue will be there. But if I am implementing the routing using then this issue will not be there. Can you help me out how can I resolve this issue? – Rudar Daman Singla Jan 29 '21 at 05:41

0 Answers0