3

I am trying to pass callback func to my android native view but i get error. Can I pass callback to view as props or it is only available as invoking react method?

Here 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(){}}/>

react-native run-android pass without error but on emulator i am getting "Unrecognized type: interface com.facebook.bridge.Callback for method : com.rmtgesture.RMTGestureManager#onChange"

2

1 Answer 1

4

Yes, currently they don't support callbacks in ReactProp annotated methods ReactProp.java

Use events instead! Example: ReactSwitchManager.java

Sign up to request clarification or add additional context in comments.

1 Comment

Really? How is this not yet supported? Seems like such a basic feature

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.