mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
Add guard around mapDom event listener (#594)
Fixes an issue where, even if the end user has a proper google maps API mock, the GoogleMaps component will throw an error when in a test env. ReactDOM.findDOMNode(this.googleMapDom_) returns `null`. This commit wraps the subsequent addEventListener call in an `if` block, ensuring that an empty DOM doesn't add complications to test suites
This commit is contained in:
parent
d6576f226f
commit
99c3c847bb
@ -249,11 +249,10 @@ export default class GoogleMap extends Component {
|
||||
const mapDom = ReactDOM.findDOMNode(this.googleMapDom_);
|
||||
// gmap can't prevent map drag if mousedown event already occured
|
||||
// the only workaround I find is prevent mousedown native browser event
|
||||
ReactDOM.findDOMNode(this.googleMapDom_).addEventListener(
|
||||
'mousedown',
|
||||
this._onMapMouseDownNative,
|
||||
true
|
||||
);
|
||||
|
||||
if (mapDom) {
|
||||
mapDom.addEventListener('mousedown', this._onMapMouseDownNative, true);
|
||||
}
|
||||
|
||||
window.addEventListener('mouseup', this._onChildMouseUp, false);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user