close
問題:使用map()函數把laps元素都呈現出來,但怎麼沒有東西return出來?
lapsList() {
this.state.laps.map((data) => {
return (
<View><Text>{data.time}</Text></View>
)
})
}
答:要在this.state.laps.map 前面加上 "return"才行
Don't forget to return
the mapped array , like:
lapsList() {
return this.state.laps.map((data) => {
return (
<View><Text>{data.time}</Text></View>
)
})
}
Reference for the map()
method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
--
全站熱搜
留言列表