0

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

I am getting this error when in nextJs when I wrap an Image tag inside a Link tag :

<Link href="/">
   <Image src={logo} width={50} height={50} className="btn rounded-full bg-transparent" />
</Link>
1

1 Answer 1

3

That error means that the element you passed cannot be used to forward a ref, so using any element that does allow that will work. Typically you'll wrap it in an <a> tag in this case. i.e.

<Link>
   <a>
      <Image />
   </a>
</Link>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.