Avoid null error (#570)

Avoid the error "Cannot read property 'removeEventListener' of null"
This commit is contained in:
Alexander Sundli-Härdig 2018-05-25 12:05:45 +02:00 committed by Michael Diego
parent cdd6ec658f
commit d6576f226f

View File

@ -396,9 +396,11 @@ export default class GoogleMap extends Component {
componentWillUnmount() {
this.mounted_ = false;
const mapDom = ReactDOM.findDOMNode(this.googleMapDom_);
if (mapDom) {
mapDom.removeEventListener('mousedown', this._onMapMouseDownNative, true);
}
window.removeEventListener('resize', this._onWindowResize);
window.removeEventListener('keydown', this._onKeyDownCapture);
mapDom.removeEventListener('mousedown', this._onMapMouseDownNative, true);
window.removeEventListener('mouseup', this._onChildMouseUp, false);
if (this.props.resetBoundsOnResize) {
detectElementResize.removeResizeListener(