您的位置:首页 > 运维架构

Cannot read property map of undefined

2020-07-14 05:49 549 查看

原代码:

报错信息:

TypeError: Cannot read property 'map' of undefined

ListUi.render

src/Demo1/listUI.jsx:13

[code]  10 | {/* ref={input => this.input = input} */}
11 | <input value={this.props.inpValue} onChange={this.props.changeValue}  />
12 | <button onClick={this.props.addValue}>增加</button>
> 13 | <ul>
| ^  14 |     {
15 |         this.props.list.map((item,index)=>{
16 |             return (

View compiled

 

 

原因:调用map的对象是 undefined,初始化第一次渲染的时候异步数据返回之前list是undefined。

 

修改之后

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐