diff --git a/src/google_map.js b/src/google_map.js index 0206fb7..5aa9801 100644 --- a/src/google_map.js +++ b/src/google_map.js @@ -1,4 +1,6 @@ import React, {PropTypes, Component} from 'react'; +import { isReact14 } from './utils/react_version.js'; + import shouldPureComponentUpdate from 'react-pure-render/function'; import MarkerDispatcher from './marker_dispatcher.js'; @@ -19,6 +21,11 @@ import pick from 'lodash.pick'; import assign from 'lodash.assign'; import isNumber from 'lodash.isnumber'; +const ReactDOM = isReact14(React) + ? require('react-dom') + : React; + + const kEPS = 0.00001; const K_GOOGLE_TILE_SIZE = 256; @@ -135,7 +142,7 @@ export default class GoogleMap extends Component { const mapOptions = {...defaultOptions, ...options, ...propsOptions}; - const map = new maps.Map(React.findDOMNode(this.refs.google_map_dom), mapOptions); + const map = new maps.Map(ReactDOM.findDOMNode(this.refs.google_map_dom), mapOptions); this.map_ = map; this.maps_ = maps; @@ -158,7 +165,7 @@ export default class GoogleMap extends Component { const panes = this.getPanes(); panes.overlayMouseTarget.appendChild(div); - React.render(( + ReactDOM.render(( { - const mapDom = React.findDOMNode(this.refs.google_map_dom); + const mapDom = ReactDOM.findDOMNode(this.refs.google_map_dom); this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight); this._onBoundsChanged(); } diff --git a/src/utils/react_version.js b/src/utils/react_version.js new file mode 100644 index 0000000..1ee2789 --- /dev/null +++ b/src/utils/react_version.js @@ -0,0 +1,13 @@ + +export function isReact14(React) { + const { version } = React; + if (typeof version !== 'string') { + return false; + } + + const sections = version.split('.'); + const major = parseInt(sections[0], 10); + const minor = parseInt(sections[1], 10); + + return major === 0 && minor > 13; +}