From ebc18688f06d5fa518e2ffe558fe5a3f8b07b25d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 6 Apr 2022 01:55:38 +0100 Subject: [PATCH] Fix flashing on zoom --- src/components/space/carto/Map.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/space/carto/Map.js b/src/components/space/carto/Map.js index 580249c..e688c93 100644 --- a/src/components/space/carto/Map.js +++ b/src/components/space/carto/Map.js @@ -2,6 +2,7 @@ import { bindActionCreators } from "redux"; import "leaflet"; import React from "react"; +import { flushSync } from "react-dom"; import { Portal } from "react-portal"; import Supercluster from "supercluster"; import { isMobileOnly } from "react-device-detect"; @@ -173,8 +174,10 @@ class Map extends React.Component { this.map.dragging.enable(); this.map.doubleClickZoom.enable(); this.map.scrollWheelZoom.enable(); - this.alignLayers(); - this.updateClusters(); + flushSync(() => { + this.alignLayers(); + this.updateClusters(); + }); }); map.on("zoomstart", () => { if (this.svgRef.current !== null)