【发布时间】:2019-05-14 22:19:44
【问题描述】:
我想添加一个清除按钮以方便用户:
constructor(props) {
this.emailInput = React.createRef();
}
<Field label="Email" name="email" ref={this.emailInput} onChange={onChange} component={TextField}/>
但是得到这个:
Warning: Function components cannot be given refs. Attempts to access this ref will fail.
【问题讨论】: