From 67d4ede37159faaeb3b6027cd2c832e037b527c9 Mon Sep 17 00:00:00 2001 From: Anderson Veiga Date: Tue, 13 Mar 2018 16:55:38 +0100 Subject: [PATCH] Remove event listeners (#459) * Remove event listeners before removing DOM elements to prevent events from firing when DOM element is not present * ESLint fix --- src/Map.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Map.js b/src/Map.js index 112c0e56..6f35ea65 100644 --- a/src/Map.js +++ b/src/Map.js @@ -336,6 +336,10 @@ export default class Map extends MapComponent { componentWillUnmount() { super.componentWillUnmount() + + this.leafletElement.off('move', this.onViewportChange) + this.leafletElement.off('moveend', this.onViewportChanged) + // The canvas renderer uses requestAnimationFrame, making a deferred call to a deleted object // When preferCanvas is set, use simpler teardown logic if (this.props.preferCanvas === true) {