1

我有以下问题,不能包裹我的头。我正在关注react-native-maps示例并尝试设置标记。然而.MAP()不断出现的错误:反应原生this.props.screenProps.mapLoc.markers.map不是一个函数

this.props.screenProps.mapLoc.markers.map is not a function

的代码是:

 <MapView 
      style={{ left:0, right: 0, top:0, bottom: 0, position: 'absolute', backgroundColor: '#fff' }} 
      region={this.state.region} 
      onRegionChange={this.onRegionChange.bind(this)} 
     > 
      {this.props.screenProps.mapLoc.markers.map(marker => (
      <MapView.Marker 
       coordinate={marker.Coords} 
       title={marker.Name} 
       description={marker.Description} 
      /> 
     ))} 
     </MapView> 

数据是params为存在和应该:

{"screenProps":{"cats":[],"mapLoc":{"markers":{"Name":"Blank","Description":"Blank","Coords":{"latitude":56.947902,"longitude":24.097722}}}},"navigation":{"state":{"key":"Map","routeName":"Map"}}}

不知道是怎么回事。

回答

0

物件没有功能map(),only arrays do

this.props.screenProps.mapLoc.markers是一个对象。

相关问题