Removes redundant state and corrects the cycle day prop
This commit is contained in:
+1
-11
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
|
|||||||
import { View, BackHandler } from 'react-native'
|
import { View, BackHandler } from 'react-native'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { LocalDate } from 'js-joda'
|
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
import { getDate, setDate } from '../slices/date'
|
import { getDate, setDate } from '../slices/date'
|
||||||
@@ -27,13 +26,6 @@ class App extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.todayDateString = LocalDate.now().toString()
|
|
||||||
props.setDate(this.todayDateString)
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
cycleDay: getCycleDay(this.todayDateString),
|
|
||||||
}
|
|
||||||
|
|
||||||
this.backHandler = BackHandler.addEventListener(
|
this.backHandler = BackHandler.addEventListener(
|
||||||
'hardwareBackPress',
|
'hardwareBackPress',
|
||||||
props.goBack
|
props.goBack
|
||||||
@@ -54,8 +46,6 @@ class App extends Component {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cycleDay } = this.state
|
|
||||||
|
|
||||||
const Page = viewsList[currentPage]
|
const Page = viewsList[currentPage]
|
||||||
const title = headerTitles[currentPage]
|
const title = headerTitles[currentPage]
|
||||||
|
|
||||||
@@ -69,7 +59,7 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pageProps = {
|
const pageProps = {
|
||||||
cycleDay,
|
cycleDay: date && getCycleDay(date),
|
||||||
date,
|
date,
|
||||||
handleBackButtonPress: goBack,
|
handleBackButtonPress: goBack,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user