Closed truescotian closed 5 years ago
Hi, since isFormValid is a promise, you should use it as promise, yes:
handleError = () => {
this.form.isFormValid().then(isValid => {
this.setState({ disabled: !isValid });
});
};
using validationListener
yes, this is current way to do this
Cheers, was able to add custom validators, listener, and that handleError to get it to work nicely. Thanks!
After going through the issue: https://github.com/NewOldMax/react-form-validator-core/issues/41
And trying to implement the solution in codepen, here: https://codesandbox.io/s/pedantic-davinci-sxudm
After switching the
handleError
to handle the promise fromisFormValid
instead of the old boolean, I'm having troubles toggling disabled in state to disable/enable the submit button.If a form is invalid, this is fine as
handleError
sets disabled in state to true. However, when the form is valid I'd assumehandleError
doesn't get called, so other than creating our ownisValid
function which returnstrue
orfalse
and constantly calling it perhaps usingvalidationListener
(maybe?), is there a solid way to determine a valid form so that the button is enabled?I'm also going to have additional login in
handleSubmit
, but figuring out a solution to the above problem would be useful to start! Any info is appreciated.