我正在尝试将回调函数传递给我的android原生视图,但是我收到了错误。我可以将回调传递给视图作为道具,还是仅作为调用反应方法?
这是我的代码:
Package.java
public class RMTGesturePackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Arrays.<ViewManager>asList(
new RMTGestureManager());
}
RMTGestureManager.java
@ReactProp(name="onChangeCallback")
public void onChange(RMTGlSurfaceView rmtGlSurfaceView, final Callback onChangeCallback) {
}
NativeGesture.js
<NativeRMTGesture onChangeCallback={function(){}}/>
react-native run-android传递没有错误,但在模拟器上我得到“无法识别的类型:接口com.facebook.bridge.Callback方法: com.rmtgesture.RMTGestureManager#的onChange“