mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 17:33:21 +08:00
Convert from React.createClass to ES6 classes
Reviewed By: cpojer Differential Revision: D3619143 fbshipit-source-id: e14e81468d467437ee3d79c34c34b7780a46ca1c
This commit is contained in:
committed by
Facebook Github Bot 8
parent
857d2b8eae
commit
a2fb703bbb
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user