Simplify calendar recalculate method
This commit is contained in:
+9
-11
@@ -18,20 +18,18 @@ export default class CalendarView extends Component {
|
|||||||
todayInCalFormat: todayToCalFormat()
|
todayInCalFormat: todayToCalFormat()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setStateWithCalFormattedDays = (function (CalendarComponent) {
|
|
||||||
return function() {
|
|
||||||
const predictedMenses = cycleModule().getPredictedMenses()
|
|
||||||
CalendarComponent.setState({
|
|
||||||
bleedingDaysInCalFormat: toCalFormat(this.bleedingDays),
|
|
||||||
predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses),
|
|
||||||
todayInCalFormat: todayToCalFormat()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})(this)
|
|
||||||
|
|
||||||
this.bleedingDays.addListener(this.setStateWithCalFormattedDays)
|
this.bleedingDays.addListener(this.setStateWithCalFormattedDays)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setStateWithCalFormattedDays = () => {
|
||||||
|
const predictedMenses = cycleModule().getPredictedMenses()
|
||||||
|
this.setState({
|
||||||
|
bleedingDaysInCalFormat: toCalFormat(this.bleedingDays),
|
||||||
|
predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses),
|
||||||
|
todayInCalFormat: todayToCalFormat()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.bleedingDays.removeListener(this.setStateWithCalFormattedDays)
|
this.bleedingDays.removeListener(this.setStateWithCalFormattedDays)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user