Discussions
React native new arch issue with method overload
4 months ago by Gabriel Rohden
I'm getting this
E | ReactNativeJS ▶︎ Error: Exception in HostObject::get for prop 'UserLeapBindings': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotations from native module: UserLeapBindings. Details: Module exports two methods to JavaScript with the same name: "configure
I don't see where I could submit a PR to fix it so here's a patch package for it
diff --git a/node_modules/react-native-userleap/android/src/main/java/com/userleap/reactnative/UserLeapModule.java b/node_modules/react-native-userleap/android/src/main/java/com/userleap/reactnative/UserLeapModule.java
index 06c35af..21bbc4a 100644
--- a/node_modules/react-native-userleap/android/src/main/java/com/userleap/reactnative/UserLeapModule.java
+++ b/node_modules/react-native-userleap/android/src/main/java/com/userleap/reactnative/UserLeapModule.java
@@ -51,14 +51,13 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
return visitorIdentifierObject == null ? "" : visitorIdentifierObject;
}
- @ReactMethod
- public void configure(String environment) {
- UserLeap.INSTANCE.configure(reactContext, environment);
- }
-
@ReactMethod
public void configure(String environment, ReadableMap configuration) {
- UserLeap.INSTANCE.configure(reactContext, environment, stringifyMap(configuration));
+ if (configuration == null) {
+ UserLeap.INSTANCE.configure(reactContext, environment);
+ } else {
+ UserLeap.INSTANCE.configure(reactContext, environment, stringifyMap(configuration));
+ }
}
@ReactMethod
I did debug the runtime and despite having only a call for the configure(env) signature, it was always called for the two args signature, and the weird part is that the configuration
was never null... dunno, but this seems to solve for me