I have read in the Lightning Component Developer guide that it is recommended to use the component.isValid()
check any time you are referencing a component in asynchronous code such as in the helper controller when handling the response from the server-side controller. I have not been able to find in the documentation exactly what this function is doing. Could someone explain what this isValid()
function is doing?
Thank you for any information you can provide.
This is an example from the developer guide of how it is used:
({
getExpenses: function (component) {
var action = component.get("c.getExpenses");
var self = this;
action.setCallback(this, function(response) {
var state = response.getState();
if (***component.isValid()*** && state === "SUCCESS") {
component.set("v.expenses", response.getReturnValue());
self.updateTotal(component);
}
});
$A.enqueueAction(action);
},