digidem / react-dimensions

[Looking for maintainers]
http://lab.digital-democracy.org/react-dimensions/
450 stars 77 forks source link

elementResize event listener fires after unmount #44

Closed karleberts closed 8 years ago

karleberts commented 8 years ago

Normally, when the component is unmounted, window.removeEventListener is called for the resize handler. If, however, you are using the 'elementResize' config option, the handler can end up being called after the component is unmounted.

Perhaps adding a check in the getWidth function to see if the element still exists could make this safer?

gmaclennan commented 8 years ago

Upstream: https://github.com/KyleAMathews/element-resize-event/pull/11 An alternative would be to use https://github.com/wnr/element-resize-detector but it is a large library.

KyleAMathews commented 8 years ago

Released 2.0.7 w/ @karleberts' fix.