How do you tell if react redux form submit attempt has occurred?

时间:2018-02-01 18:02:52

标签: reactjs redux react-redux react-redux-form

When I look at the $form of my form, I see the following boolean properties:

focus
pending
pristine
retouched
submitFailed
submitted
touched
valid
validated
validating

In need to determine if an attempt was made to submit the form, whether it be successful or not. I would expect the submitted property or even submitFailed to be used to indicate that, but not so. If I open a form and immediately submit it, both of those properties are false. The only time either is true is if I attempt to submit (unsuccessfully) and then correct any errors. In that case, submitFailed turns true.

Something on $form should indicate if a submit has ever been attempted.

1 个答案:

答案 0 :(得分:0)

您在列表中遗漏了submitSucceeded。这告诉表单是否已提交,在验证错误后它将恢复为false。如果这对您不起作用,可以使用reducer.plugin添加reducer并使用表单的操作减少submitAttempt值(或者将自己的reducer添加到rootReducer中)。

https://redux-form.com/7.2.1/docs/api/reducerplugin.md/