這是問題: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 = '下標(biāo)為:'+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>}跪求?。?!
- 0 回答
- 0 關(guān)注
- 911 瀏覽
添加回答
舉報(bào)
0/150
提交
取消