Closed pavanshinde47 closed 6 years ago
Hi, for now you can do something like this
<ValidatorForm ref={r => (this.form = r)} >
runFormvalidation = () => {
const result = this.form.walk(this.form.childs); // result will be true or false
}
Hi
I called runFormvalidation function from render method then showing continuously warning.
runFormvalidation = () => { if(!isEmpty(this.refs)){ const result = this.refs.form.walk(this.refs.form.childs); // result will be true or false return result } }
warning.js:33 Warning: setState(...): Cannot update during an existing state transition (such as within render
or another component's constructor)
As you can see in your warning message, you shouldn't call this function in render method. You should do it in some event action, like onChange
<ValidatorForm onChange={this.runFormvalidation} />
From version 0.4.3
you can use isFormValid
method
@NewOldMax Thanks
@NewOldMax Hi, I'm currently using the library at the latest version (0.4.4), and I couldn't find a way to use that method, since it's not exposed in the react class. Could you please post an example of how to use it?
I tried using it the same way as addValidationRule
@arosas-atix
<ValidatorForm
ref={r => (this.form = r)}
>
...
this.form.isFormValid();
Hi,
Can you add a property or method to the ValidatorForm to see if the whole form is valid or not.
Something like
isValid=()=> { this.childs.map(child => { if(child.isValid) { return true } }); return false }