From ceed82e4f3457c9907cd88c5f135e452e5b139e9 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Wed, 21 Oct 2020 18:33:06 +0300 Subject: [PATCH] fix corner case where clusters sometimes remain on screen without events --- src/components/Map.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 5aa680b..e41e1c6 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -45,6 +45,7 @@ class Map extends React.Component { if (this.map === null) { this.initializeMap() } + window.dispatchEvent(new Event('resize')) } componentWillReceiveProps (nextProps) { @@ -75,8 +76,11 @@ class Map extends React.Component { } componentDidUpdate (prevState, prevProps) { - if (prevState.domain.locations.length > 0 && this.state.clusters.length === 0) { - this.loadClusterData(prevState.domain.locations) + // HACK: this is required because of something to do with Leaflet and the + // React lifecycle not playing nice... if you don't put this conditional, + // then the map sometimes appear blank on first load. + if (this.props.domain.locations.length > 0 && this.state.clusters.length === 0) { + this.loadClusterData(this.props.domain.locations) } }