react-scroll icon indicating copy to clipboard operation
react-scroll copied to clipboard

New set of listeners created on each click, not removed on leave

Open emilecollin opened this issue 3 years ago • 0 comments

I have this React component:

import React from 'react';
import { animateScroll as scroll } from 'react-scroll';

const Test: React.FC = () => {
  const scrollToTop = () => {
    scroll.scrollToTop();
  };

  return <div onClick={scrollToTop}>Test</div>;
};

export default Test;

On each click, a new set of keydown, mousedown, mousewheel and touchmove are created. Here we have it on Chrome Devtools after four clicks:

wbahO

They are not removed on leave.

Not sure whats the usual procedure to remove them, but probably they should be cleaned for each click.

emilecollin avatar Feb 20 '21 09:02 emilecollin