Currently using withFormik, we have access to the handleSubmit method which will be called when the form is submitted and validation passes.
A method that is called when validation fails, for example, onValidationError. This can be used for an functionality you want to implement when the user tries to submit an invalid form.
Example: You may wish to scroll to an error message.
An onValidationError method that is called instead of handleSubmit if the validation fails.
This is for all users
Currently I am using the componentDidUpdate lifecycle method of my form element to check if a submission has taken place and now there are errors
componentDidUpdate = (prevProps) => {
// if form was submitting, but now is not submitting because it is invalid
if (prevProps.isSubmitting && !this.props.isSubmitting && !this.props.isValid) {
//scroll to top
window.scrollTo(0, 0);
}
}
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.
I still think this would be a useful piece of functionality.
This will definitely be a nice functionality to have!
Duplicate #1484
Most helpful comment
This will definitely be a nice functionality to have!