首页 > 解决方案 > HEREMaps 反应无法读取未定义的属性

问题描述

目前正在尝试使用react-here-maps,但我没有运气使用它。

import React, { Component } from 'react';
import HEREMap from 'react-here-maps';
import PropTypes from 'prop-types';

export default class Map extends Component {
    render() {
        return (
            <HEREMap
                appId="KEY"
                appCode="KEY"
                center={{ lat: 0, lng: 0 }}
                zoom={14}
            />
        )
    }
}

在我的应用程序中使用此组件时,它会给出错误

TypeError: Cannot read property 'object' of undefined

第一个详细的错误行是这个

     55 | }
  56 | // define the context types that are passed down from a <HEREMap> instance
  57 | Circle.contextTypes = {
> 58 |     map: React.PropTypes.object
  59 | };
  60 | Circle.defaultProps = {
  61 |     fillColor: "rgba(255, 255, 255, 0.5)",

我认为它与proptypes有关,但我已经安装了它。任何人都知道如何解决这个问题?

标签: javascriptreactjsmapstypeerror

解决方案


推荐阅读