mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 18:01:17 +01:00
Cleanup popup nodes
Before, the component instances used for rendering popup content were kept around, slowly leaking memory. This could be observed using react developer tools.
This commit is contained in:
parent
84654e81af
commit
8f391d7d52
1 changed files with 7 additions and 7 deletions
|
@ -17,10 +17,12 @@ import '../../libs/mapbox-rtl'
|
|||
|
||||
const IS_SUPPORTED = MapboxGl.supported();
|
||||
|
||||
function renderPropertyPopup(features) {
|
||||
function renderPopup(popup) {
|
||||
var mountNode = document.createElement('div');
|
||||
ReactDOM.render(<FeaturePropertyPopup features={features} />, mountNode)
|
||||
return mountNode.innerHTML;
|
||||
ReactDOM.render(popup, mountNode)
|
||||
var content = mountNode.innerHTML;
|
||||
ReactDOM.unmountComponentAtNode(mountNode);
|
||||
return content;
|
||||
}
|
||||
|
||||
function buildInspectStyle(originalMapStyle, coloredLayers, highlightedLayer) {
|
||||
|
@ -162,11 +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 renderPropertyPopup(features)
|
||||
return renderPopup(<FeaturePropertyPopup features={features} />);
|
||||
} else {
|
||||
var mountNode = document.createElement('div');
|
||||
ReactDOM.render(<FeatureLayerPopup features={features} onLayerSelect={this.props.onLayerSelect} />, mountNode)
|
||||
return mountNode
|
||||
return renderPopup(<FeatureLayerPopup features={features} onLayerSelect={this.props.onLayerSelect} />);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue