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 {
requireNativeComponent,
View,
......@@ -9,7 +9,7 @@ import {
import {LatLng} from './PropTypes'
import Overlay from './Overlay'
export default class Marker extends Component {
export default class Marker extends PureComponent {
static propTypes = {
...ViewPropTypes,
......
......@@ -65,13 +65,7 @@ export default class Polyline extends PureComponent {
colors: [],
}
_handle(name) {
return event => {
if (this.props[name]) {
this.props[name](event)
}
}
}
_onPress = event => this.props.onPress && this.props.onPress(event)
render() {
const props = {
......@@ -82,7 +76,7 @@ export default class Polyline extends PureComponent {
colors: this.props.colors.map(processColor),
},
}),
onPolylineClick: this._handle('onPress'),
onPolylineClick: this._onPress,
}
return <AMapPolyline {...props}/>
}
......
import React, {Component} from 'react'
import {StyleSheet, View} from 'react-native'
import {StyleSheet} from 'react-native'
import {MapView, Circle} from 'react-native-amap3d'
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