whoisandy / react-rangeslider

A lightweight responsive react range slider component.A fast & lightweight react component as a drop in replacement for HTML5 input range slider element.
https://whoisandy.github.io/react-rangeslider/
MIT License
641 stars 235 forks source link

ResizeObserver not being unmounted alongside rangeslider component #100

Open DolpZanso opened 6 years ago

DolpZanso commented 6 years ago

Hello. I found an issue where the resizeobserver that is being used with the rangeslider is still active even though the component has been unmounted. I observed this because my next page holds a react-id-swiper component, which generates a 'transitionend' event whenever it swipes. The resizeobserver has a transitionend event listener which triggers, and causes an error, because the resizeobserver was not properly disconnected on unmount of the rangeslider. Can you please help in fixing this? Many thanks

bongtavas commented 6 years ago

This happens because the resizeObserver is not disconnected in unmount. https://github.com/whoisandy/react-rangeslider/blob/28b957e41feb78624a52ecee204018e928873b6f/src/Rangeslider.js#L71

We might need to add

componentWillUnmount () {
  resizeObserver.unobserve(this.slider);
}