Hey there! I'm currently working on implementing a countdown timer, but I keep encountering a console error that says 'You may have an infinite update loop in a component render function.' It seems like something needs to be adjusted.
export default {
data: () => ({
timeDiff: 0,
time: {
days: 0,
hours: 0,
minutes: 0,
seconds: 0,
},
}),
created(){
this.startCountdown();
},
methods: {
startCountdown() {
setTimeout(() => {
if (this.$store.state.allDataLoaded) {
var countDownDate = new Date('December 17, 2019 03:24:00');
var now = new Date();
this.timeDiff = countDownDate - now;
this.time.days = Math.floor(this.timeDiff / (1000 * 60 * 60 * 24));
this.time.hours = Math.floor((this.timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
this.time.minutes = Math.floor((this.timeDiff % (1000 * 60 * 60)) / (1000 * 60));
this.time.seconds = Math.floor((this.timeDiff % (1000 * 60)) / 1000);
} else {
this.timeDiff = -1;
this.time.days = 0;
this.time.hours = 0;
this.time.minutes = 0;
this.time.seconds = 0;
}
this.startCountdown()
}, 1000)
},
},
computed: {
timeDifferenceComp(){
return this.timeDiff
},
timeComponents(){
return this.time
},
}
};