Closed haresh6x closed 2 years ago
According to the docs, we can use purgeFields() method in class based components like this
purgeFields()
render() { this.validator.purgeFields(); return ( <div> <div className="form-group"> <label>Address Line 1</label> <input className="form-control" value={this.state.title} onChange={this.setTitle} /> {this.validator.message('title', this.state.title, 'required|alpha')} </div> {this.optinallyAddAnotherAddressLine()} <button className="btn btn-primary" onClick={this.submitForm}>Save Review</button> </div> ); }
The doubt is that how do I use it in functional based components?
It would just run before the code is returned and should be the same for functional components.
According to the docs, we can use
purgeFields()
method in class based components like thisThe doubt is that how do I use it in functional based components?