From 080102cd3786660b07f6f82d1b0b4ce6017e9020 Mon Sep 17 00:00:00 2001 From: efarooqui Date: Wed, 21 Oct 2020 10:03:21 -0700 Subject: [PATCH] Working index load on initial map render; needed to add callback to set state function --- src/components/Map.jsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 8490e11..35545d3 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -75,15 +75,6 @@ class Map extends React.Component { } } - componentDidUpdate (prevState, prevProps) { - // 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) - } - } - initializeMap () { /** * Creates a Leaflet map and a tilelayer for the map background @@ -175,8 +166,9 @@ class Map extends React.Component { return acc }, []) this.superclusterIndex.load(convertedLocations) - this.setState({ indexLoaded: true }) - this.updateClusters() + this.setState({ indexLoaded: true }, () => { + this.updateClusters() + }) } else { this.setState({ clusters: [] }) }