Redux form ile çalışmak için oturum formumda alan doğrulaması alma konusunda sorun yaşıyorum. Şimdilik, sadece senkronizasyonu doğrulamaya çalışıyorum, böylece temel hataları kontrol edebilirim. Sorun, formun yalnızca bileşen monte edildiğinde doğrulama yapıldığını, sonra da o noktadan sonra tekrarlamayacağını göstermektedir. İşte ben kod:redux-form alanları form yüklendikten sonra yeniden oluşturma/güncelleştirme
import React from 'react';
import { Field, reduxForm } from 'redux-form';
import * as Redux from 'react-redux';
import Input from './../../helpers/Input';
import Button from './../../helpers/Button';
export const Signup = React.createClass({
renderInput({ label, type, input: { value }, meta: { touched, error }}){
return (
<Input label={ label }
type={ type }
filled={ value ? true : false }
touched={ touched }
error={ error } />
);
},
render(){
const { handleSubmit } = this.props;
return(
<div>
<form onSubmit={ handleSubmit }>
<Field name="email" label="Email" component={ this.renderInput } />
<Field name="username" label="Username" component={ this.renderInput } />
<Field name="password" label="Password" type="password" component={ this.renderInput } />
<Field name="confirmPassword" label="Confirm Password" type="password" component={ this.renderInput } />
<Button type="submit" btnType="main" btnIcon="" btnText="Create Account" />
</form>
</div>
);
}
});
export const validate = values => {
const errors = {};
if (!values.username) {
errors.username = 'Required';
} else if (values.username.length > 15) {
errors.username = 'Must be 15 characters or less';
}
if (!values.email) {
errors.email = 'Required';
} else if (!/^[A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) {
errors.email = 'Invalid email address';
}
console.log(errors);
return errors;
};
export default reduxForm({
form: 'signup',
validate
})(Signup);
ben burada çok temel bir şey eksik seziyorum ama stumped. "Dokunma" özelliğini onurlandırmak (ve böylece formu tekrarlamak) için bir eylemin gönderilmesi gerektiğini düşünüyorum, ancak bunu yapmakta görünmüyor ve redux-formdaki dokümanlar aracılığıyla bu gibi bir şey bulamadım. . Herhangi bir fikir?