问题是当react在根树之外渲染新组件时,我无法处理并卸载:
createInfoWindow = (e, map, place, marker) => {
let container = 0;
infoWindow = new window.google.maps.InfoWindow({
content: '<div id=infoWindow />',
position: {lat: e.latLng.lat(), lng: e.latLng.lng()},
});
infoWindow.addListener('domready', e => {
ReactDOM.render(<InfoWindow
ref={this.ref}
desc={place.description}
clicked={() => this.onClickHandler(place.id)}/>,
document.getElementById('infoWindow'))
});
infoWindow.open(map, marker);
// ReactDOM.unmountComponentAtNode(document.getElementById('infoWindow'))
};