I have an error I don't understand when I activate the Debug Mode in my sandbox. Message: [Invariant Violation: Updating the template of [object:vm v (127)] has side effects on the state of [object:vm v (127)].startDate]
@track startDate;
@track endDate;
@track month;
@track diffMonth;
@track currentMonth;
//Getter
get createHeader(){
this.sDate = new Date(this.opportunity.data.fields.Start_Date__c.value);
this.startDate = this.sDate.getMonth();
this.currentMonth = this.startDate;
this.eDate = new Date(this.opportunity.data.fields.End_Date__c.value);
this.endDate = this.eDate.getMonth();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
this.headerArray.splice(0, this.headerArray.length);
this.amountArray.splice(0, this.amountArray.length);
this.scheduleMonths.splice(0, this.scheduleMonths.length);
this.headerArray.push('Product');
this.headerArray.push('Description');
this.diffMonth = this.endDate-this.startDate;
if(this.diffMonth < 0){
this.diffMonth = (this.endDate + 12) - this.startDate;
var count = this.diffMonth;
while(count >= 0){
if(this.currentMonth > 11){
this.currentMonth = 0;
}
this.headerArray.push(month[this.currentMonth]);
this.amountArray.push('0');
this.scheduleMonths.push('Schedule ' + month[this.currentMonth]);
this.currentMonth++;
count--;
}
}else{
while(this.startDate < (this.endDate + 1)){
this.headerArray.push(month[this.startDate]);
this.scheduleMonths.push('Schedule ' + month[this.startDate]);
this.amountArray.push('0');
this.startDate++;
}
}
return this.headerArray;
}
Thanks Eric
this.sDate
... is that a var on the controller? If not, it's undeclared. If you are using as a temp var, just define it aslet sDate = ...