这是问题:Warning: Each child in an array or iterator should have a unique "key" prop.
这是代码:requestData = () => {
fetch(url).then(res => {
console.log('started fetch');
return res.json()
}).then(res => {
console.log(res.list);
let dataBlob=res.list;
this.setState({
//data: [...this.state.data, ...res],
data: dataBlob,
error: res.error || null,
laoding: false,
refreshing: false,
});
}).catch(err => {
console.log('==> fetch error', err);
this.setState({ error: err, loading: false, refreshing: false});
});
};
renderItem = (item) => {
var txt = '下标为:'+item.index+'姓名'+item.item.userName;
var bgColor = item.index % 2 == 0 ? 'red' : 'blue';
return <Text style={[{flex:1,height:200,backgroundColor:bgColor},styles.txt]}>{txt}</Text>
}
跪求!!!
慕设计2395807
相关分类