我想处理平面列表索引。我想将平面列表索引转换为messageID
我的主要请求,我想更改平面清单项目数据
我有这样的json数组;
this.state.messages = [
{
"date": "09:55",
"longDate": "22/10/2018",
"message": "ghjghj",
"messageID": 157,
"senderID": 1,
"showLongDate": 0,
"type": "text",
"uri": ""
},
{
"date": "09:56",
"longDate": "22/10/2018",
"message": "rtyrtyrt",
"messageID": 158,
"senderID": 1,
"showLongDate": 0,
"type": "text",
"uri": ""
}
]
我的单位列表;
<FlatList
ref={(list) => this.myFlatList = list}
data={this.state.messages}
renderItem={({item, index})=>(
<View><Text>{item.message}</Text></View>
)}
removeClippedSubviews={true}
refreshing={this.state.refreshing}
keyExtractor={(item, index) => item.messageID.toString()}
onRefresh={this.handleRefresh}
extraData={this.state}
/>
答案 0 :(得分:0)
<FlatList
ref={(list) => this.myFlatList = list}
data={list}
renderItem={({item, index})=>(
<View /><Text>{item.message}</Text></View>
)}
removeClippedSubviews={true}
refreshing={this.state.refreshing}
keyExtractor={(item, index) => item.message.toString()}
onRefresh={this.handleRefresh}
extraData={this.state}
/>