From d8c8f5034e1dc8708a3a6c68883f7cfaaefe6c5f Mon Sep 17 00:00:00 2001
From: Julia Friesel <julia.friesel@gmail.com>
Date: Mon, 17 Sep 2018 16:01:21 +0200
Subject: [PATCH] Simplify calendar recalculate method

---
 components/calendar.js | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/components/calendar.js b/components/calendar.js
index d9a0fd9a..4ffce88e 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)
   }
-- 
GitLab