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:00:02 -07:00
committed by Facebook Github Bot 8
parent 857d2b8eae
commit a2fb703bbb
133 changed files with 2124 additions and 2191 deletions

View File

@@ -160,16 +160,13 @@ var MapRegionInput = React.createClass({
});
var MapViewExample = React.createClass({
getInitialState() {
return {
isFirstLoad: true,
mapRegion: undefined,
mapRegionInput: undefined,
annotations: [],
};
},
class MapViewExample extends React.Component {
state = {
isFirstLoad: true,
mapRegion: undefined,
mapRegionInput: undefined,
annotations: [],
};
render() {
return (
@@ -187,23 +184,23 @@ var MapViewExample = React.createClass({
/>
</View>
);
},
}
_getAnnotations(region) {
_getAnnotations = (region) => {
return [{
longitude: region.longitude,
latitude: region.latitude,
title: 'You Are Here',
}];
},
};
_onRegionChange(region) {
_onRegionChange = (region) => {
this.setState({
mapRegionInput: region,
});
},
};
_onRegionChangeComplete(region) {
_onRegionChangeComplete = (region) => {
if (this.state.isFirstLoad) {
this.setState({
mapRegionInput: region,
@@ -211,27 +208,23 @@ var MapViewExample = React.createClass({
isFirstLoad: false,
});
}
},
};
_onRegionInputChanged(region) {
_onRegionInputChanged = (region) => {
this.setState({
mapRegion: region,
mapRegionInput: region,
annotations: this._getAnnotations(region),
});
},
};
}
});
var AnnotationExample = React.createClass({
getInitialState() {
return {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
},
class AnnotationExample extends React.Component {
state = {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
render() {
if (this.state.isFirstLoad) {
@@ -255,13 +248,17 @@ var AnnotationExample = React.createClass({
annotations={this.state.annotations}
/>
);
},
}
}
});
class DraggableAnnotationExample extends React.Component {
state = {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
var DraggableAnnotationExample = React.createClass({
createAnnotation(longitude, latitude) {
createAnnotation = (longitude, latitude) => {
return {
longitude,
latitude,
@@ -275,15 +272,7 @@ var DraggableAnnotationExample = React.createClass({
console.log('Drag state: ' + event.state);
},
};
},
getInitialState() {
return {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
},
};
render() {
if (this.state.isFirstLoad) {
@@ -305,9 +294,8 @@ var DraggableAnnotationExample = React.createClass({
annotations={this.state.annotations}
/>
);
},
});
}
}
var styles = StyleSheet.create({
map: {