-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Closed
Description
Bug report
Describe the bug
In Next 8, the ref attached to an <a> element inside of <Link> was working correctly. With the introduction of intersection observer in Next 9, it looks like this ref is getting overwritten, even with prefetch disabled.
To Reproduce
Here's an example page:
import Link from "next/link";
import { useRef, useEffect } from "react";
const Home = () => {
const buttonRef = useRef();
useEffect(() => {
console.log("buttonRef", buttonRef);
});
return (
<Link href="/">
<a ref={buttonRef}>click me</a>
</Link>
);
};
export default Home;
Steps to reproduce the behavior:
- Load the page
- Check the console
Expected behavior
buttonRef.current's value in Next 8 is a reference to the <a> tag. In Next 9, it's undefined.
System information
- Version of Next.js: 9.0.0
Additional context
Not sure if this is an intended breaking change, but would be useful documented if so.
TimPchelintsev, izorg, binura-g, alexlafroscia, spiderbites and 11 more
Metadata
Metadata
Assignees
Labels
No labels