Convert from React.createClass to ES6 classes

Reviewed By: cpojer

Differential Revision: D3619143

fbshipit-source-id: e14e81468d467437ee3d79c34c34b7780a46ca1c
This commit is contained in:
Ben Alpert
2016-07-26 01:13:31 -07:00
committed by Facebook Github Bot 8
parent 857d2b8eae
commit a2fb703bbb
133 changed files with 2124 additions and 2191 deletions
+12 -14
View File
@@ -45,17 +45,15 @@ exports.examples = [
}
];
var GeolocationExample = React.createClass({
watchID: (null: ?number),
class GeolocationExample extends React.Component {
state = {
initialPosition: 'unknown',
lastPosition: 'unknown',
};
getInitialState: function() {
return {
initialPosition: 'unknown',
lastPosition: 'unknown',
};
},
watchID: ?number = null;
componentDidMount: function() {
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
var initialPosition = JSON.stringify(position);
@@ -68,13 +66,13 @@ var GeolocationExample = React.createClass({
var lastPosition = JSON.stringify(position);
this.setState({lastPosition});
});
},
}
componentWillUnmount: function() {
componentWillUnmount() {
navigator.geolocation.clearWatch(this.watchID);
},
}
render: function() {
render() {
return (
<View>
<Text>
@@ -88,7 +86,7 @@ var GeolocationExample = React.createClass({
</View>
);
}
});
}
var styles = StyleSheet.create({
title: {