Respond to local callbacks
•
Android
I tried to pass the callback function to my android native view, but there was an error. Can I treat it as a prop through the callback, or can I only use it by calling the react method?
This is my code:
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(){}}/>
There is no error when react native runs Android delivery, but on the simulator, I get "method unrecognized: interface com.facebook.bridge.callback: com.rmtgest.rmtgest manager #onchange“
resolvent:
Yes, at present, they do not support the callback reactprop.java in the reactprop annotation method
Please use event instead! Example: reactswitchmanager.java
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码