谷歌地图 - 反应不起作用

时间:2017-05-08 17:03:38

标签: google-maps reactjs google-maps-react

我正在使用与es2015 javascript的反应,当我使用google-maps-react包时,我在我的控制台中遇到以下异常:

  

warning.js:36警告:通过主React包访​​问PropTypes   已弃用。请改用npm中的prop-types包。

map.jsx:

import React , {Component} from 'react';
import {Map} from 'google-maps-react';

class MapView extends Component{
  render(){
    return(
      <div className="google-map">
          <Map google={this.props.google} zoom={14} />
      </div>
    )
  }
}

export default MapView;

1 个答案:

答案 0 :(得分:1)

从React v15.5.0 开始,propTypes已移出React模块;它现在有自己的prop-types包。阅读博客文章https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html

您必须使用以下内容导入它,而不是使用React.PropTypes.whatever

import PropTypes from 'prop-types';

(请务必使用npm install --save prop-types

进行安装
相关问题