I have two images and got to display one of them every alternate day. I'm using http://momentjs.com/ and checking if the storedDate = currentDate as per below code. However, I see that the state of the storeDate is not getting updated. Could anyone shed some light here?
getInitialState() {
storedDate: ''
}
onDateChanged(currentDate) {
this.setState({ storedDate: currentDate });
},
render(){
var currentDate = moment();
var displayImage;
if (currentDate.isSame(this.state.storedDate, 'day')) {
displayImage = Image1;
this.onDateChanged(currentDate);
} else {
displayImage = Image2;
}
}