From 1375240bfa7461333043be541d7b5714d8285cb3 Mon Sep 17 00:00:00 2001 From: Alexander Clausen Date: Sun, 6 Jan 2019 06:01:04 +0100 Subject: [PATCH] For better debuggability, actually keep one popup node around --- src/components/map/MapboxGlMap.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/map/MapboxGlMap.jsx b/src/components/map/MapboxGlMap.jsx index 59349d08..0e2afa54 100644 --- a/src/components/map/MapboxGlMap.jsx +++ b/src/components/map/MapboxGlMap.jsx @@ -17,11 +17,9 @@ import '../../libs/mapbox-rtl' const IS_SUPPORTED = MapboxGl.supported(); -function renderPopup(popup) { - var mountNode = document.createElement('div'); - ReactDOM.render(popup, mountNode) +function renderPopup(popup, mountNode) { + ReactDOM.render(popup, mountNode); var content = mountNode.innerHTML; - ReactDOM.unmountComponentAtNode(mountNode); return content; } @@ -149,6 +147,8 @@ export default class MapboxGlMap extends React.Component { const nav = new MapboxGl.NavigationControl(); map.addControl(nav, 'top-right'); + const tmpNode = document.createElement('div'); + const inspect = new MapboxInspect({ popup: new MapboxGl.Popup({ closeOnClick: false @@ -164,9 +164,9 @@ export default class MapboxGlMap extends React.Component { buildInspectStyle: (originalMapStyle, coloredLayers) => buildInspectStyle(originalMapStyle, coloredLayers, this.props.highlightedLayer), renderPopup: features => { if(this.props.inspectModeEnabled) { - return renderPopup(); + return renderPopup(, tmpNode); } else { - return renderPopup(); + return renderPopup(, tmpNode); } } })