react-google-maps icon indicating copy to clipboard operation
react-google-maps copied to clipboard

GoogleMapHolder.js:53 Uncaught TypeError: Cannot read property 'object' of undefined

Open ttson24 opened this issue 8 years ago • 3 comments

i use this code.

mport React, { Component } from 'react';
import PropTypes from 'prop-types';
import { GoogleMapLoader, GoogleMap } from 'react-google-maps';

class MapGoogle extends Component {
  constructor(props){
    super(props);
    console.log("lon" + this.props)
  }
  render(){
    return(
      <GoogleMapLoader containerElement={<div style={{height:'100%'}}></div>}
                       googleMapElement={
                         <GoogleMap defaultZoom={12}
                                    defaultCenter={{lat: -25.363882, lng: 131.044922}}/>
                       }
        />
    );
  }
}
MapGoogle.propTypes = {
  lat: PropTypes.number,
  lng: PropTypes.number
}
export default (MapGoogle);

when i run project, i have to error: GoogleMapHolder.js:53 Uncaught TypeError: Cannot read property 'object' of undefined

ttson24 avatar Jan 06 '18 19:01 ttson24

I have run into a similar issue – it raises when defining the prop types. For example, in GoogleMaps.js:

var controlledPropTypes = {
  center: _react.PropTypes.object, // boom, _react.PropTypes is undefined

This is on React v16.0.0, where prop-types has been extracted to a separate library, so I assume that's why it's failing.

schrockwell avatar Jan 14 '18 15:01 schrockwell

@ttson24 Turns out I was running an old version (v6.0.3) of react-google-maps. Make sure you update to the latest version (v9.4.5 currently)

schrockwell avatar Jan 14 '18 15:01 schrockwell

Thank you @schrockwell . That worked for me

tevin-morake avatar Feb 13 '20 10:02 tevin-morake