为了账号安全,请及时绑定邮箱和手机立即绑定

我用的faltlist做的显示列表,后台传的是个list集合在前台让它显示。总是报要有唯一的key?

我用的faltlist做的显示列表,后台传的是个list集合在前台让它显示。总是报要有唯一的key?

慕前端332230 2018-05-02 19:34:19
这是问题: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>}跪求!!!
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 883 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信