Skip to content

Commit 5a5fad7

Browse files
committed
Convert NavButton to ES6
1 parent d3c0307 commit 5a5fad7

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

components/NavButton.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
'use strict';
1+
import React from 'react-native';
22

3-
var React = require('react-native');
4-
5-
var {
3+
const {
64
StyleSheet,
75
Text,
86
View,
97
TouchableHighlight,
8+
Component,
109
} = React;
1110

11+
class NavButton extends Component {
12+
constructor(props) {
13+
super(props);
1214

13-
var NavButton = React.createClass({
15+
this.onPress = this.onPress.bind(this);
16+
}
1417

15-
onPress: function() {
18+
onPress() {
1619
this.props.onPress();
17-
},
20+
}
1821

1922
render() {
20-
var backButton,
21-
BackButton;
23+
let backButton;
24+
let BackButton;
2225

2326
if (this.props.backButtonComponent) {
2427
BackButton = this.props.backButtonComponent;
25-
backButton = <View><BackButton/></View>
28+
backButton = <View><BackButton/></View>;
2629
} else {
27-
backButton = <Text style={styles.navbarText}>Back</Text>
30+
backButton = <Text style={styles.navbarText}>Back</Text>;
2831
}
2932

3033
return (
@@ -33,19 +36,17 @@ var NavButton = React.createClass({
3336
</TouchableHighlight>
3437
);
3538
}
36-
});
39+
}
3740

38-
39-
var styles = StyleSheet.create({
41+
const styles = StyleSheet.create({
4042
navbarText: {
4143
color: 'white',
4244
fontSize: 16,
4345
margin: 10,
4446
fontWeight: '600',
4547
textAlign: 'center',
4648
alignItems: 'center',
47-
}
49+
},
4850
});
4951

50-
51-
module.exports = NavButton;
52+
export default NavButton;

0 commit comments

Comments
 (0)