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

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of GalleryByReactApp. See https://fb.me/react-warning-keys for more information.

http://img1.sycdn.imooc.com//58d2478200013d3112970288.jpgb

请有大神知道这两条报错的原因么?

render: function () {
    var imgFigures = [],
        controllerUnits = [];

    imageDatas.forEach(function (value, index) {

        if (!this.state.imgsArrangeArr[index]) {
            this.state.imgsArrangeArr[index] = {
                pos: {
                    left: 0,
                    top: 0
                }
            };
        }

        imgFigures.push(<ImgFigure data={value} ref={'imgFigure' + index} arrange={this.state.imgsArrangeArr[index]}/>);
    }.bind(this));


    return (
        <section className="stage" ref="stage">
            <section className="img-sec">
                {imgFigures}
            </section>
            <nav className="controller-nav">
                {controllerUnits}
            </nav>
        </section>
    );
}


正在回答

1 回答

给<ImgFigure>标签中加一个key={index}  就好了

1 回复 有任何疑惑可以回复我~
#1

枫叶咚咚咚

感谢!
2018-01-31 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
React实战--打造画廊应用(上)
  • 参与学习       57313    人
  • 解答问题       273    个

颠覆式前端UI开发框架 React,打造图片画廊实践案讲解

进入课程

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of GalleryByReactApp. See https://fb.me/react-warning-keys for more information.

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信