diff --git a/components/calendar.js b/components/calendar.js index d9a0fd9a52c8784913126f5463ed53959974d01a..4ffce88eed7b09eaa5aa5620197f1b1606cdeda8 100644 --- a/components/calendar.js +++ b/components/calendar.js @@ -18,20 +18,18 @@ export default class CalendarView extends Component { 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) } + setStateWithCalFormattedDays = () => { + const predictedMenses = cycleModule().getPredictedMenses() + this.setState({ + bleedingDaysInCalFormat: toCalFormat(this.bleedingDays), + predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses), + todayInCalFormat: todayToCalFormat() + }) + } + componentWillUnmount() { this.bleedingDays.removeListener(this.setStateWithCalFormattedDays) }