Commit 98874aeb authored by Qiu Xiang's avatar Qiu Xiang

优化组件代码

parent 1dd57591
import React, {PropTypes, Component} from 'react' import React, {PropTypes, PureComponent} from 'react'
import { import {
requireNativeComponent, requireNativeComponent,
View, View,
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
import {LatLng} from './PropTypes' import {LatLng} from './PropTypes'
import Overlay from './Overlay' import Overlay from './Overlay'
export default class Marker extends Component { export default class Marker extends PureComponent {
static propTypes = { static propTypes = {
...ViewPropTypes, ...ViewPropTypes,
......
...@@ -65,13 +65,7 @@ export default class Polyline extends PureComponent { ...@@ -65,13 +65,7 @@ export default class Polyline extends PureComponent {
colors: [], colors: [],
} }
_handle(name) { _onPress = event => this.props.onPress && this.props.onPress(event)
return event => {
if (this.props[name]) {
this.props[name](event)
}
}
}
render() { render() {
const props = { const props = {
...@@ -82,7 +76,7 @@ export default class Polyline extends PureComponent { ...@@ -82,7 +76,7 @@ export default class Polyline extends PureComponent {
colors: this.props.colors.map(processColor), colors: this.props.colors.map(processColor),
}, },
}), }),
onPolylineClick: this._handle('onPress'), onPolylineClick: this._onPress,
} }
return <AMapPolyline {...props}/> return <AMapPolyline {...props}/>
} }
......
import React, {Component} from 'react' import React, {Component} from 'react'
import {StyleSheet, View} from 'react-native' import {StyleSheet} from 'react-native'
import {MapView, Circle} from 'react-native-amap3d' import {MapView, Circle} from 'react-native-amap3d'
export default class CircleExample extends Component { export default class CircleExample extends Component {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment