我想添加一个清除按钮以方便用户:
constructor(props) {
this.emailInput = React.createRef();
}
<Field label="Email" name="email" ref={this.emailInput} onChange={onChange} component={TextField}/>
Run Code Online (Sandbox Code Playgroud)
但是得到这个:
Warning: Function components cannot be given refs. Attempts to access this ref will fail.