Ich bin neu, um native zu reagieren. Während ich ein nationales Modul entwickelte, stoße ich auf ein Problem mit Rückrufen.
unten finden Sie die Fehlermeldung von React Native < /p>
02-05 17:43:26.387 32301-32570/com.awesomeproject2 E/ReactNativeJNI: Got JS Exception: Exception calling object as function: abc,function f1() {
_ToastExample2.default.show('1111', _ToastExample2.default.SHORT);
},72,73 is not usable as a native method argument (:1845)
02-05 17:43:26.387 32301-32570/com.awesomeproject2 E/ReactNativeJNI: Got JS Stack: invariant@http://localhost:8081/index.delta?platf ... se:1838:26
enqueueNativeCall@http://localhost:8081/index.delta?platf ... se:2259:20
fn@http://localhost:8081/index.delta?platf ... se:1999:40
onBtnPress@http://localhost:8081/index.delta?platf ... e:58362:32
proxiedMethod@http://localhost:8081/index.delta?platf ... e:34324:37
proxiedMethod@[native code]
touchableHandlePress@http://localhost:8081/index.delta?platf ... e:37170:47
touchableHandlePress@[native code]
_performSideEffectsForTransition@http://localhost:8081/index.delta?platf ... e:36821:36
_performSideEffectsForTransition@[native code]
_receiveSignal@http://localhost:8081/index.delta?platf ... e:36754:46
_receiveSignal@[native code]
touchableHandleResponderRelease@http://localhost:8081/index.delta?platf ... d&dev=true&
02-05 17:43:26.393 32301-32570/com.awesomeproject2 E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Error calling RCTEventEmitter.receiveTouches
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:135)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.facebook.jni.CppException: Exception calling object as function: abc,function f1() {
_ToastExample2.default.show('1111', _ToastExample2.default.SHORT);
},72,73 is not usable as a native method argument (:1845)
... 7 more
< /code>
und mein natives Modul sehen so aus < /p>
@ReactMethod
public void testCallback(String message, Callback c1, Callback c2, Callback c3) {
if (message.equals("123")) {
c1.invoke(message);
} else if (message.equals("abc")) {
c2.invoke(message);
} else {
c3.invoke(message);
}
}
< /code>
und meine Aufruffunktion von React < /p>
onBtnPress() {
function f1 () {
ToastExample.show('1111', ToastExample.SHORT);
};
function f2 () {
ToastExample.show('2222', ToastExample.SHORT);
};
function f3 () {
ToastExample.show('3333', ToastExample.SHORT);
};
ToastExample.testCallback('abc', f1, f2, f3);
}
< /code>
Ich habe keine Ahnung, warum dieser Fehler passiert. Kann mir jemand helfen? Danke.
React Native, "ist nicht als Argument der nativen Methode verwendbar." ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post