Gets rid of a top level prop passed down through a tree of components
This commit is contained in:
@@ -63,7 +63,6 @@ class App extends Component {
|
||||
const pageProps = {
|
||||
cycleDay: date && getCycleDay(date),
|
||||
date,
|
||||
handleBackButtonPress: goBack,
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -14,7 +14,6 @@ class Bleeding extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -54,7 +53,6 @@ class Bleeding extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -14,7 +14,6 @@ class Cervix extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -62,7 +61,6 @@ class Cervix extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -13,7 +13,6 @@ class Desire extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -50,7 +49,6 @@ class Desire extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -13,7 +13,6 @@ class Mood extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -64,7 +63,6 @@ class Mood extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -15,7 +15,6 @@ class Mucus extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -63,7 +62,6 @@ class Mucus extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -39,7 +39,6 @@ class Note extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -14,7 +14,6 @@ class Pain extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -65,7 +64,6 @@ class Pain extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -14,7 +14,6 @@ class Sex extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -65,7 +64,6 @@ class Sex extends Component {
|
||||
<SymptomView
|
||||
symptom={this.symptom}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types'
|
||||
|
||||
import { connect } from 'react-redux'
|
||||
import { getDate } from '../../../slices/date'
|
||||
import { goBack } from '../../../slices/navigation'
|
||||
|
||||
import { saveSymptom } from '../../../db'
|
||||
import formatDate from '../../helpers/format-date'
|
||||
@@ -27,8 +28,8 @@ class SymptomView extends Component {
|
||||
symptom: PropTypes.string.isRequired,
|
||||
values: PropTypes.object,
|
||||
date: PropTypes.string,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
children: PropTypes.node,
|
||||
goBack: PropTypes.func,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@@ -52,7 +53,7 @@ class SymptomView extends Component {
|
||||
|
||||
onDeleteConfirmation = () => {
|
||||
this.deleteSymptomEntry()
|
||||
this.props.handleBackButtonPress()
|
||||
this.props.goBack()
|
||||
}
|
||||
|
||||
showConfirmationAlert = () => {
|
||||
@@ -75,13 +76,13 @@ class SymptomView extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { symptom, date } = this.props
|
||||
const { symptom, date, goBack } = this.props
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<Header
|
||||
title={headerTitles[symptom]}
|
||||
subtitle={formatDate(date)}
|
||||
handleBack={this.props.handleBackButtonPress}
|
||||
handleBack={goBack}
|
||||
handleDelete={
|
||||
this.state.shouldShowDelete && this.showConfirmationAlert
|
||||
}
|
||||
@@ -99,11 +100,17 @@ class SymptomView extends Component {
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return({
|
||||
date: getDate(state)
|
||||
date: getDate(state),
|
||||
})
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return({
|
||||
goBack: () => dispatch(goBack()),
|
||||
})
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
mapDispatchToProps,
|
||||
)(SymptomView)
|
||||
|
||||
@@ -20,7 +20,6 @@ class Temperature extends Component {
|
||||
|
||||
static propTypes = {
|
||||
cycleDay: PropTypes.object,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
@@ -90,7 +89,6 @@ class Temperature extends Component {
|
||||
<SymptomView
|
||||
symptom={'temperature'}
|
||||
values={this.state}
|
||||
handleBackButtonPress={this.props.handleBackButtonPress}
|
||||
date={this.props.date}
|
||||
>
|
||||
<SymptomSection
|
||||
|
||||
+1
-2
@@ -30,11 +30,10 @@ class Home extends Component {
|
||||
static propTypes = {
|
||||
navigate: PropTypes.func,
|
||||
setDate: PropTypes.func,
|
||||
// The following three is not being used,
|
||||
// The following are not being used,
|
||||
// we could see if it's possible to not pass them from the <App />
|
||||
cycleDay: PropTypes.object,
|
||||
date: PropTypes.string,
|
||||
handleBackButtonPress: PropTypes.func,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
|
||||
Reference in New Issue
Block a user