From 31b23f010158fe775b50e50b9a38e2c06e2f2623 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sat, 4 Apr 2020 12:14:15 -0700 Subject: [PATCH 1/3] Add a fix for the redraw bug. --- src/HeatmapLayer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/HeatmapLayer.js b/src/HeatmapLayer.js index 7534929..2eec3f6 100644 --- a/src/HeatmapLayer.js +++ b/src/HeatmapLayer.js @@ -294,6 +294,12 @@ export default withLeaflet(class HeatmapLayer extends MapLayer { } redraw(): void { + // It's possible that the map has unmounted while we've waited for an animation frame, so we + // need to check that it still exists before proceeding with the redraw. + if (!this.props.leaflet.map._mapPane) { + return; + } + const r = this._heatmap._r; const size = this.props.leaflet.map.getSize(); From 3d8bdd535c83ba11bd39b087f5e53ed4789a6a31 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sat, 4 Apr 2020 12:14:55 -0700 Subject: [PATCH 2/3] Update the compiled version of the library. --- lib/HeatmapLayer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/HeatmapLayer.js b/lib/HeatmapLayer.js index fac909d..49af6a5 100644 --- a/lib/HeatmapLayer.js +++ b/lib/HeatmapLayer.js @@ -306,6 +306,12 @@ exports.default = (0, _reactLeaflet.withLeaflet)((_temp = _class = function (_Ma }; HeatmapLayer.prototype.redraw = function redraw() { + // It's possible that the map has unmounted while we've waited for an animation frame, so we + // need to check that it still exists before proceeding with the redraw. + if (!this.props.leaflet.map._mapPane) { + return; + } + var r = this._heatmap._r; var size = this.props.leaflet.map.getSize(); From 39b68828a1a28fd741072ecc82b534d7c891d606 Mon Sep 17 00:00:00 2001 From: Evan Sangaline Date: Sat, 4 Apr 2020 12:17:34 -0700 Subject: [PATCH 3/3] Bump the package version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6735b02..66d9c67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-leaflet-heatmap-layer", - "version": "2.0.0", + "version": "2.0.1", "description": "A custom layer for heatmaps in react-leaflet", "main": "lib/HeatmapLayer.js", "scripts": {