From 96ca404638506040395844198ada14d739f8773d Mon Sep 17 00:00:00 2001 From: Jeff Chan Date: Sat, 2 Dec 2017 15:37:51 -0800 Subject: [PATCH] Update Popup element only after render is complete Fixes https://github.com/PaulLeCam/react-leaflet/issues/422 --- src/Popup.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Popup.js b/src/Popup.js index 6d87e6ae..b7d8e6ec 100644 --- a/src/Popup.js +++ b/src/Popup.js @@ -129,14 +129,16 @@ export default class Popup extends MapComponent { render( Children.only(this.props.children), this.leafletElement._contentNode, + () => { + this.leafletElement.update() + if (this.props.autoPan !== false) { + if (this.leafletElement._map && this.leafletElement._map._panAnim) { + this.leafletElement._map._panAnim = undefined + } + this.leafletElement._adjustPan() + } + }, ) - this.leafletElement.update() - if (this.props.autoPan !== false) { - if (this.leafletElement._map && this.leafletElement._map._panAnim) { - this.leafletElement._map._panAnim = undefined - } - this.leafletElement._adjustPan() - } } }