我有一个要迁移到的反应组件
tsx
文件和我得到一个错误
Property 'name' does not exist on type 'NameComponent'
.
这是我的组件:
class NameComponent extends React.Component<NameComponentProps> {
render() {
return (
<Modal>
<Modal.Header>
Enter Name
</Modal.Header>
<Modal.Body>
<FormGroup>
<ControlLabel>Name: </ControlLabel>
<FormControl type="text"
placeholder='Enter name'
inputRef={(ref) => this.name = ref}
onChange={() => this.props.onValidate({ name: this.name.value })}
/>
<FormControl.Feedback />
</FormGroup>
</Modal.Body>
</Modal>
);
}
}
有一个红色的不死线出现在
this.name
. 当我把这个文件放进去的时候,它就恢复了
.js
格式。
如何解决此错误?