From 4adef73ab867db43d2fca66e409c8607da2d8c15 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sun, 14 Jul 2019 10:23:13 -0700 Subject: [PATCH] Update link ref handling to clean up previous listeners (#7943) --- packages/next/client/link.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/next/client/link.tsx b/packages/next/client/link.tsx index 833f34061a8ee..ebc3990554c58 100644 --- a/packages/next/client/link.tsx +++ b/packages/next/client/link.tsx @@ -113,16 +113,13 @@ class Link extends Component { cleanUpListeners = () => {} - componentDidMount() { - this.cleanUpListeners = () => {} - } - componentWillUnmount() { this.cleanUpListeners() } handleRef(ref: Element) { if (this.props.prefetch && IntersectionObserver && ref && ref.tagName) { + this.cleanUpListeners() this.cleanUpListeners = listenToIntersections(ref, () => { this.prefetch() })