React key值问题
来源:互联网 发布:华驰网络 编辑:程序博客网 时间:2024/05/22 03:14
报错:
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `List`. See https://fb.me/react-warning-keys for more information.
in ItemEditor (created by List)
in List
1.解决方案:http://blog.csdn.net/liuzijiang1123/article/details/66974630;
2.可以设置new Map()对象;
var List = React.createClass({
getInitialState:function(){
return{
key:0,
list:new Map(),
editList:new Map()
}
},
add:function(){
const key = ++this.state.key;
this.state.editList.set(key,{value:''});
this.forceUpdate();
},
render:function(){
const listDOM=[];
const editListDOM=[];
for(let item of this.state.list){
listDOM.push(<Item value={item.value} key={item}/>);
}
for(let item of this.state.editList){
editListDOM.push(<ItemEditor value={item.value} key={item} />);
}
return(
<div>
<div className="container">
<button className="btn btn-default" onClick={this.add}>Add</button>
<ul className="list-group">
{listDOM}
{editListDOM}
</ul>
</div>
</div>
)
}
})
- React key值问题
- React之key详解
- Map中key值问题
- java HashMap插入重复Key值问题
- java HashMap插入重复Key值问题
- mapreduce对key值排序问题
- 关于百度地图 key值的问题
- java HashMap插入重复Key值问题
- 百度地图key值问题小记
- java HashMap插入重复Key值问题
- jquery对象key值保存变量问题
- react组件内部不能获取key
- React-Native中Array的key警告
- React----List(集合)和Key(键)
- 浅谈react和Vue传值问题
- react和vue的传值问题
- ssh key 的问题
- MYSQL中KEY问题
- 谷歌自曝无人驾驶核心技术!700亿估值Waymo炼成之谜【附下载】| 智东西内参
- Java设计模式之模板模式(Template )
- Android设计模式(一)
- LeetCode——141. Linked List Cycle && 142. Linked List Cycle II
- 快速排序 quick sort
- React key值问题
- 马化腾:我创办腾讯的这些年
- 全球AI报告:探索人工智能革命
- 大牛激辩:AI 该像婴儿一样生来就懂事,还是该从零学习?
- 科学:螳螂虾大脑拥有记忆和学习中心
- 深度丨我们可以有多信任人工智能
- “芯”战争,人工智能芯片研发攻略
- Gartner公布:2018年十大战略科技发展趋势 研发战略演进研究榜单
- 谷歌全方位自曝Waymo无人车技术方案 | 42页报告要点解读+下载