[英]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.