reactjs - 未捕获的类型错误:this.props.onUpdateUser
问题描述
我收到 Uncaught TypeError: this.props.onUpdateUser is not a function error。我在构造函数中也完成了绑定。但是为什么当我在文本框中写任何东西时它总是抛出同样的错误。
class App extends Component {
constructor(props){
super(props);
this.onUpdateUser = this.onUpdateUser.bind(this);
}
onUpdateUser(event){
this.props.onUpdateUser(event.target.value);
}
render() {
console.log(this.props);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<input onChange={this.onUpdateUser}/>
{this.props.user}
</header>
</div>
);
}
}
解决方案
推荐阅读
- amazon-web-services - 无法访问不同 VPC 中的另一个实例
- elasticsearch - 如何从备份恢复到新索引?
- mysql - 在 MySql 中将小时格式转换为 hh:mm:format
- java - Jackson json解析忽略属性
- python - Pandas Rolling:如何从左到右或从上到下滚动?
- c++ - 如何在不同的文件中使用定义/声明多个命名空间级别的类
- c# - 在托盘应用程序中闪烁托盘图标(C# windows 窗体)
- javascript - Bootbox.confirm javascript
- python - Python 的 SciPy interpolate.rbf 函数的 Objective C 或 Swift 实现
- vba - VBA/VB6 中的古代日期(2 位数年份)