fix(src/google_map.js): remove unnecessary findDOMNode references, use ref directly (#1243)

This commit is contained in:
Michael Altamirano 2025-03-11 14:18:39 -07:00 committed by GitHub
parent 6fe7e11c4f
commit 153fa44ab8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, react/forbid-prop-types, react/no-find-dom-node, no-console, no-undef */ /* eslint-disable import/no-extraneous-dependencies, react/forbid-prop-types, no-console, no-undef */
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
@ -262,7 +262,7 @@ class GoogleMap extends Component {
this.markersDispatcher_ = new MarkerDispatcher(this); this.markersDispatcher_ = new MarkerDispatcher(this);
addPassiveEventListener(window, 'resize', this._onWindowResize, false); addPassiveEventListener(window, 'resize', this._onWindowResize, false);
addPassiveEventListener(window, 'keydown', this._onKeyDownCapture, true); addPassiveEventListener(window, 'keydown', this._onKeyDownCapture, true);
const mapDom = ReactDOM.findDOMNode(this.googleMapDom_); const mapDom = this.googleMapDom_;
// gmap can't prevent map drag if mousedown event already occured // gmap can't prevent map drag if mousedown event already occured
// the only workaround I find is prevent mousedown native browser event // the only workaround I find is prevent mousedown native browser event
@ -435,7 +435,7 @@ class GoogleMap extends Component {
componentWillUnmount() { componentWillUnmount() {
this.mounted_ = false; this.mounted_ = false;
const mapDom = ReactDOM.findDOMNode(this.googleMapDom_); const mapDom = this.googleMapDom_;
if (mapDom) { if (mapDom) {
mapDom.removeEventListener('mousedown', this._onMapMouseDownNative, true); mapDom.removeEventListener('mousedown', this._onMapMouseDownNative, true);
} }
@ -617,10 +617,7 @@ class GoogleMap extends Component {
mapOptions.minZoom = _checkMinZoom(mapOptions.minZoom, minZoom); mapOptions.minZoom = _checkMinZoom(mapOptions.minZoom, minZoom);
const map = new maps.Map( const map = new maps.Map(this.googleMapDom_, mapOptions);
ReactDOM.findDOMNode(this.googleMapDom_),
mapOptions
);
this.map_ = map; this.map_ = map;
this.maps_ = maps; this.maps_ = maps;
@ -936,7 +933,7 @@ class GoogleMap extends Component {
if (isFullScreen()) { if (isFullScreen()) {
this.geoService_.setViewSize(window.innerWidth, window.innerHeight); this.geoService_.setViewSize(window.innerWidth, window.innerHeight);
} else { } else {
const mapDom = ReactDOM.findDOMNode(this.googleMapDom_); const mapDom = this.googleMapDom_;
this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight); this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight);
} }
this._onBoundsChanged(); this._onBoundsChanged();