Replace binds with lambdas
This commit is contained in:
+14
-15
@@ -19,28 +19,27 @@ export default class App extends Component {
|
||||
this.state = {
|
||||
currentPage: 'Home'
|
||||
}
|
||||
|
||||
const handleBackButtonPress = function() {
|
||||
if (this.state.currentPage === 'Home') return false
|
||||
if (isSymptomView(this.state.currentPage)) {
|
||||
this.navigate('CycleDay', {cycleDay: this.state.currentProps.cycleDay})
|
||||
} else {
|
||||
this.navigate('Home')
|
||||
}
|
||||
return true
|
||||
}.bind(this)
|
||||
|
||||
this.backHandler = BackHandler.addEventListener('hardwareBackPress', handleBackButtonPress)
|
||||
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonPress)
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.backHandler.remove()
|
||||
}
|
||||
|
||||
navigate(pageName, props) {
|
||||
navigate = (pageName, props) => {
|
||||
this.setState({currentPage: pageName, currentProps: props})
|
||||
}
|
||||
|
||||
handleBackButtonPress = () => {
|
||||
if (this.state.currentPage === 'Home') return false
|
||||
if (isSymptomView(this.state.currentPage)) {
|
||||
this.navigate('CycleDay', { cycleDay: this.state.currentProps.cycleDay })
|
||||
} else {
|
||||
this.navigate('Home')
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
render() {
|
||||
const page = {
|
||||
Home, Calendar, CycleDay, Chart, Settings, Stats, ...symptomViews
|
||||
@@ -51,12 +50,12 @@ export default class App extends Component {
|
||||
{this.state.currentPage != 'CycleDay' && <Header title={titles[this.state.currentPage]} />}
|
||||
|
||||
{React.createElement(page, {
|
||||
navigate: this.navigate.bind(this),
|
||||
navigate: this.navigate,
|
||||
...this.state.currentProps
|
||||
})}
|
||||
|
||||
{!isSymptomView(this.state.currentPage) &&
|
||||
<Menu navigate={this.navigate.bind(this)} />
|
||||
<Menu navigate={this.navigate} />
|
||||
}
|
||||
</View>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user