原代码:
报错信息:
TypeError: Cannot read property 'map' of undefined
ListUi.render
src/Demo1/listUI.jsx:13
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。
修改之后
因篇幅问题不能全部显示,请点此查看更多更全内容