Skip to content

Commit

Permalink
Remove event listeners (#459)
Browse files Browse the repository at this point in the history
* Remove event listeners before removing DOM elements to prevent events from firing when DOM element is not present

* ESLint fix
  • Loading branch information
imanderson authored and PaulLeCam committed Mar 13, 2018
1 parent 2d24847 commit 67d4ede
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ export default class Map extends MapComponent<LeafletElement, Props> {

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) {
Expand Down

0 comments on commit 67d4ede

Please sign in to comment.