I need to fire a function passed down in props if the form (powered by formik obviously) has failed the validation after submit. It should happen only after clicking submit, not on every re-render.
What's the best approach for that?
submitForm = (enableValidation: boolean) => {
const { submitForm, setFieldValue } = this.props;
setFieldValue('enableValidation', enableValidation);
setTimeout(() => {
submitForm();
});
}
@latviancoder how exactly can your example help triggering a function call if validation has failed?
Good question..
You click submit button, set custom flag in values, submitForm, then use custom validate function in which you check for your flag and call/not call your function.
The main problem is how to unset your custom flag now. It's almost like you have to use setTimeout to unset it after a short pause, because you don't have an onValuesChanged callback in formik.
Like I said, it feels hacky..
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.
ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it.