【发布时间】:2017-11-30 21:06:21
【问题描述】:
我有一个处理不断变化的文本字段的函数:
private handleNameChange(e: React.FormEvent<FormControl>) {
const name = e.target.value;
this.setState({ name });
this.props.editGroupName(name);
}
这与 FormControl 的 onChange 相连:
<FormControl type='text' placeholder='Name' value={this.state.name} onChange={this.handleNameChange} />
但是,根据 TypeScript,这是错误的:
TS2339: Property 'value' does not exist on type 'EventTarget'.
我也尝试过使用currentTarget。我该如何解决这个问题?
【问题讨论】:
标签: reactjs typescript types