Closed smoosh911 closed 6 years ago
Hi
instantValidate
is not a function, it's boolean value
@NewOldMax go through the debugger. You will see that by the time it gets to the if statement I've mentioned, it is referencing the function that is pulled from the form validator. It looks like you guys are setting a boolean here but then that overrides the functions you are calling from the form validator, so then why have those? If you are just using the boolean then the function reference to form validator is pointless and you might as well remove that function.
All ValidatorComponent
's take global instantValidate
value from ValidatorForm
only once and later reuse it. And it's a boolean value, not a function, so no reference here, just taking value from context
Hi, I would like to give instantValidate
a dynamic value:
at init make it 'false' (with validations on blur),
and after trying to submit make it 'true'.
@CarmitK you can try to change it manually via ref
this.form.instantValidate = false;
this.form.instantValidate = true;
<ValidatorForm ref={r => (this.form = r}>
Using should prevent instant validation. It looks like in the ValidatorComponent.jsx you guys are checking if the this.instantValidate exists rather than calling it.
Current Code:
componentDidUpdate(prevProps, prevState) { if (**this.instantValidate** && this.props.value !== prevState.value) { this.validateDebounced(this.props.value, this.props.withRequiredValidator); } }
Suggested Fix:
componentDidUpdate(prevProps, prevState) { if (**this.instantValidate()** && this.props.value !== prevState.value) { this.validateDebounced(this.props.value, this.props.withRequiredValidator); } }