Unhandled JS Exception: Invariant Violation: Cannot have a non-function arg after a function arg., js engine: hermes
I was using the old version that had auth, events, and init methods. But now, I need to upgrade to the new one because I need the Expo plugin, and I can’t open the SDK because the app crashes when it tries to.
This is the error:
*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: Cannot have a non-function arg after a function arg., js engine: hermes', reason: 'Unhandled JS Exception: Invariant Violation: Cannot have a non-function arg after a function arg., js engine: hermes, stack:
invariant@1045:25
nonPromiseMethodWrapper@2615:37
authorize@210636:27
anonymous@210465:39
anonymous@210512:77
onPress@218805:59
invokeFunc@197525:29
trailingEdge@197565:29
timerExpired@197554:31
anonymous@17051:49
_callTimer@17000:16
callTimers@17141:18
__callFunction@1294:37
anonymous@1133:29
__guard@1240:14
callFunctionReturnFlushedQueue@1132:20
'
*** First throw call stack:
(0x18fe7e5fc 0x18d3f9244 0x1005cf3b0 0x10063c4b4 0x10063ccdc 0x18fe80e34 0x18fe7fe7c 0x18fee3a38 0x100600b90 0x100602d00 0x100602954 0x102b3488c 0x102b36578 0x102b3e454 0x102b3f25c 0x102b4c6fc 0x102b4bd0c 0x21ac10680 0x21ac0e474)
libc++abi: terminating due to uncaught exception of type NSException
And here is the js code:
const handleGetTiktokData = useCallback(() => {
authorize({
redirectURI: <URL_HERE>,
scopes: [Scopes.user.info.basic, Scopes.video.list],
callback: (authCode, codeVerifier) => {
// codeVerifier is returned only on Android
console.log(authCode, codeVerifier);
},
});
}, []);
Im also having the same issue, The reason seems to be passing "callback" as 2nd parameter. it should be final parameter
index.ts
export function authorize(props: Props): void {
const { redirectURI, callback, scopes } = props;
return Tiktok.authorize(redirectURI, callback, scopes);
}
@@Lg0gs Please share your thoughts, Thanks.
@Ishara-Mee I'm sorry for not getting back to you sooner, sometimes I don't have much free time.. Are you migrating from v1?
We have the same problem, and we've migrated from version 1.
@Ishara-Mee I'm sorry for not getting back to you sooner, sometimes I don't have much free time.. Are you migrating from v1?
No, It is a fresh installation for RN 0.73.9
Are you fix it
@quochuy2405 , I developed a native module
@quochuy2405 please try this patch
diff --git a/node_modules/react-native-tiktok/.DS_Store b/node_modules/react-native-tiktok/.DS_Store
new file mode 100644
index 0000000..e69de29
diff --git a/node_modules/react-native-tiktok/ios/Tiktok.mm b/node_modules/react-native-tiktok/ios/Tiktok.mm
index 1b3c789..8202d9c 100644
--- a/node_modules/react-native-tiktok/ios/Tiktok.mm
+++ b/node_modules/react-native-tiktok/ios/Tiktok.mm
@@ -5,8 +5,8 @@ @interface RCT_EXTERN_MODULE(Tiktok, RCTEventEmitter)
RCT_EXTERN_METHOD(
authorize: (NSString)redirectURI
- callback: (RCTResponseSenderBlock)callback
scopes:(NSArray * _Nullable)scopes
+ callback: (RCTResponseSenderBlock)callback
)
+ (BOOL)requiresMainQueueSetup
diff --git a/node_modules/react-native-tiktok/ios/Tiktok.swift b/node_modules/react-native-tiktok/ios/Tiktok.swift
index add9a0d..7342bdd 100644
--- a/node_modules/react-native-tiktok/ios/Tiktok.swift
+++ b/node_modules/react-native-tiktok/ios/Tiktok.swift
@@ -6,7 +6,7 @@ class Tiktok: RCTEventEmitter {
let authRequest = TikTokAuthRequest(scopes: [], redirectURI: "")
@objc
- func authorize(_ redirectURI: String, callback: @escaping RCTResponseSenderBlock, scopes: [String]?) -> Void {
+ func authorize(_ redirectURI: String, scopes: [String]?, callback: @escaping RCTResponseSenderBlock) -> Void {
DispatchQueue.main.async {
self.authRequest.redirectURI = redirectURI
self.authRequest.scopes = Set(scopes ?? ["user.info.basic"])
diff --git a/node_modules/react-native-tiktok/lib/commonjs/index.js b/node_modules/react-native-tiktok/lib/commonjs/index.js
index a8b792e..f03350b 100644
--- a/node_modules/react-native-tiktok/lib/commonjs/index.js
+++ b/node_modules/react-native-tiktok/lib/commonjs/index.js
@@ -31,6 +31,6 @@ function authorize(props) {
callback,
scopes
} = props;
- return Tiktok.authorize(redirectURI, callback, scopes);
+ return Tiktok.authorize(redirectURI, scopes, callback);
}
//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/node_modules/react-native-tiktok/lib/module/index.js b/node_modules/react-native-tiktok/lib/module/index.js
index 0ebe798..052b924 100644
--- a/node_modules/react-native-tiktok/lib/module/index.js
+++ b/node_modules/react-native-tiktok/lib/module/index.js
@@ -26,6 +26,6 @@ export function authorize(props) {
callback,
scopes
} = props;
- return Tiktok.authorize(redirectURI, callback, scopes);
+ return Tiktok.authorize(redirectURI, scopes, callback);
}
//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/node_modules/react-native-tiktok/src/index.tsx b/node_modules/react-native-tiktok/src/index.tsx
index bdefd47..7a7d49d 100644
--- a/node_modules/react-native-tiktok/src/index.tsx
+++ b/node_modules/react-native-tiktok/src/index.tsx
@@ -29,5 +29,5 @@ const Tiktok = NativeModules.Tiktok;
export function authorize(props: Props): void {
const { redirectURI, callback, scopes } = props;
- return Tiktok.authorize(redirectURI, callback, scopes);
+ return Tiktok.authorize(redirectURI, scopes, callback);
}
getting " com.facebook.react.bridge.ReadableNativeArray cannot be cast to java.lang.Double"