React native React原生Android原生UI组件@ReactProps不';不执行
我已经在Android平台上构建了一个地图原生UI组件。在视图中导入视图时,如下所示React native React原生Android原生UI组件@ReactProps不';不执行,react-native,React Native,我已经在Android平台上构建了一个地图原生UI组件。在视图中导入视图时,如下所示 <AMapView style={styles.mapContainer} mode={2} onRegionChange={this._onReginChange.bind(this)}/> 确保导入com.facebook.react.uimanager.annotations.ReactProp,我认为用于更改的路径和旧的ReactProp在较新的React本机版本中将不再起作用。谢谢。是的
<AMapView style={styles.mapContainer} mode={2} onRegionChange={this._onReginChange.bind(this)}/>
确保导入com.facebook.react.uimanager.annotations.ReactProp代码>,我认为用于更改的路径和旧的ReactProp在较新的React本机版本中将不再起作用。谢谢。是的,这也让我非常困惑——我不知道为什么,但Android Studio IDE建议在“导入com.facebook.react.uimanager.ReactProp;”之前先“导入com.facebook.react.uimanager.annotations.ReactProp;”。为什么它甚至建议使用非注释版本,因为该路径似乎不存在?
class AMapCustomView extends Component {
constructor(props) {
super(props)
this._onRegionChange = this._onRegionChange.bind(this)
}
_onRegionChange(event: Event) {
if (!this.props.onRegionChange) {
return
}
this.props.onRegionChange(event.nativeEvent)
}
render() {
return <RCTAMap {...this.props} onRegionChange={this._onRegionChange}/>
}
}
AMapCustomView.propTypes = {
...View.propTypes,
mode: PropTypes.number,
onRegionChange: PropTypes.func
}
var RCTAMap = requireNativeComponent('RCTAMap', AMapCustomView)
module.exports = AMapCustomView;
@Override
public Map getExportedCustomDirectEventTypeConstants() {
return MapBuilder.of(
AMapLocationEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRegionChange")
);
}
@ReactProp(name="mode", defaultInt = 1)
public void setMode(AMapView mapView, int type) {
Log.d(TAG, "mode:" + type);
}