I have an Arrow function to show the validation of form fields as:
showValidation = (field) => () => {
console.log(field);
this.setFieldState(field, {showValidation: true});
}
Now I want to call to function from another function that loops through all the form entries as:
showAllValidations() {
let self = this;
for (let field of ['a', 'b', 'c', 'd', 'e', 'f', 'g']) {
console.log(field);
self.showValidation(field);
}
}
The console.log(field)
in showValidation
doesn't print anything while the console.log(field)
in showAllValidations()
displays all the fields so I assume that it is not getting called. I am new to ReactJs & ES6 and stuck with this problem for a long time.