在键入时,UI中的输入字段不显示任何字符。同样,存储中的值仅接受最后键入的字符。例如,输入sam时,存储中的值为m,而sam将不会显示在文本字段中。
这是代码。
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { validate } from './validation';
import { reduxForm, Field } from 'redux-form';
class Login extends Component {
renderInput = ({input, meta}) =>
<div className="position-relative form-group">
<input { ...input } />
</div>
render () {
return (
<div className="login">
<form>
<Field name="identifier" component={this.renderInput}/>
<Field name="password" component={this.renderInput}/>
<div className="position-relative form-group text-center mt-5">
<button type="submit" className="login-btn btn btn-lg w-50">Login</button>
</div>
</form>
</div>
);
}
}
export default reduxForm({
form: 'login',
fields: ['identifier', 'password'],
validate,
})(Login);