地圖函數內部陣列我有一個函數:遍歷在反應天然
renderConversations(){
let conversationContent = this.state.conversationArray.map((convObj, i) => {
return <View key={i} style={[globalStyle.conversationContainer,globalStyle.shadow]}>
<Text style= {globalStyle.conversationText}>{ convObj.text }</Text>
<Text style= {globalStyle.conversationText}>{ convObj.actionButtons }</Text>
</View>
})
return conversationContent
}
我渲染使用根據狀態變量此功能的組件。我面臨的挑戰是convObj.actionButtons
這裏是一個數組。我想在map函數內部迭代構建組件。有沒有辦法在map函數中執行此操作,還是需要使用good for for循環?
是的,這將是正確的方法,使用另一種映射,並創建UI元素:) –