我有一个带用户名字段的redux表单,其中有一些验证。我的问题是,当我输入触发验证的用户名并单击“重置”按钮时,验证将显示在我的字段下,并且我的表格未清除。你知道为什么会这样吗?这是我的代码:
<FormRowInput labelFor={NEW_USERNAME} labelId={newUsernameId}>
<UsernameField
name={NEW_USERNAME}
fieldClass="text m2"
divInnerClassName="tooltipField"
tooltipId="first.time.login.username.text.tooltip"
/>
</FormRowInput>
<div className="buttonsWrap end noSpaceBtm">
<button className="gray" type="button" onClick={e => clearUsernameForm(e)}>
<FormattedMessage id="customer.clear.button" />
</button>
<button className="button blue" type="submit">
<FormattedMessage id="customer.submit.button" />
</button>
</div>
export const mapDispatchToProps = dispatch => ({
onSubmit: formData => dispatch(changeUsernameAction(formData)),
clearUsernameForm: (e) => {
dispatch(reset(CHANGE_USERNAME_FORM));
},
/**
* It requests to check if username already exists
*/
});
const ChangeUsernameForm = reduxForm({
form: CHANGE_USERNAME_FORM,
validate: changeUsernameFormValidator
})(ChangeUsername);