簡體   English   中英

不會渲染循環中的react-native-maps標記

[英]react-native-maps markers in loop are not rendered

我正在嘗試學習如何為iOS創建React本機應用程序。 我使用react-native-maps包,當我靜態渲染MapView.Marker ,它會正確渲染到地圖。 但是,當我要渲染標記數組時,什么也沒發生。

export default (props) => {

return (
  <MapView

      initialRegion={{
        latitude: 48.99568000,
        longitude: 21.24220000,
        latitudeDelta: 0.001,
        longitudeDelta: 0.01
      }}>

    {/* this works */}
      <MapView.Marker
        coordinate={{
          latitude: 48.98975,
          longitude: 21.24697
        }}
      />

    {/* this doesn't */}
  {
    props.points.nearby.map(point => {
      <MapView.Marker
        coordinate={{
          latitude: point.lat,
          longitude: point.lng
        }}
      />
    })
  }
</MapView>
);
}

props.points.nearby數組還可以,有三項

解:

正如我意識到的那樣, 帶有塊體的ES6箭頭函數不會隱式return ,所以我在map回調中添加了return語句,現在一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM