Skip to content

Commit b42371d

Browse files
RSNarafacebook-github-bot
authored andcommitted
Fix NativeJSDevSupport.onSuccess
Summary: `JSDevSupport.onSuccess` is called in `JSDevSupportModule.getJSHierarchy`: ``` const JSDevSupportModule = { getJSHierarchy: function(tag: number) { try { const { computeComponentStackForErrorReporting, } = ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; const componentStack = computeComponentStackForErrorReporting(tag); if (!componentStack) { JSDevSupport.onFailure( JSDevSupport.ERROR_CODE_VIEW_NOT_FOUND, "Component stack doesn't exist for tag " + tag, ); } else { JSDevSupport.onSuccess(componentStack); } } catch (e) { JSDevSupport.onFailure(JSDevSupport.ERROR_CODE_EXCEPTION, e.message); } }, }; ``` If you look at the implementation of `computeComponentStackForErrorReporting`, it returns a `string`. The Java NativeModule also accepts a `String` for the argument to `JSDevSupport.onSuccess`. So, I've changed the `NativeJSDevSupport.onSuccess` method signature to match the native implementation (i.e: accept a string). Changelog: [General] [Fixed] - Correct argument types of NativeJSDevSupport.onSuccess Reviewed By: fkgozali Differential Revision: D18908306 fbshipit-source-id: 1c9a5c6fe5b3a81b25baed520e586ebf7e2514f8
1 parent 3714bfe commit b42371d

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ namespace JS {
16821682
}
16831683
@protocol NativeJSDevSupportSpec <RCTBridgeModule, RCTTurboModule>
16841684

1685-
- (void)onSuccess:(NSDictionary *)data;
1685+
- (void)onSuccess:(NSString *)data;
16861686
- (void)onFailure:(double)errorCode
16871687
error:(NSString *)error;
16881688
- (facebook::react::ModuleConstants<JS::NativeJSDevSupport::Constants::Builder>)constantsToExport;

Libraries/Utilities/NativeJSDevSupport.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Spec extends TurboModule {
1818
ERROR_CODE_EXCEPTION: number,
1919
ERROR_CODE_VIEW_NOT_FOUND: number,
2020
|};
21-
+onSuccess: (data: Object) => void;
21+
+onSuccess: (data: string) => void;
2222
+onFailure: (errorCode: number, error: string) => void;
2323
}
2424

ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativeJSDevSupportSpec.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1717
import com.facebook.react.bridge.ReactMethod;
1818
import com.facebook.react.bridge.ReactModuleWithSpec;
19-
import com.facebook.react.bridge.ReadableMap;
2019
import com.facebook.react.common.build.ReactBuildConfig;
2120
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
2221
import java.util.Arrays;
@@ -34,7 +33,7 @@ public NativeJSDevSupportSpec(ReactApplicationContext reactContext) {
3433
public abstract void onFailure(double errorCode, String error);
3534

3635
@ReactMethod
37-
public abstract void onSuccess(ReadableMap data);
36+
public abstract void onSuccess(String data);
3837

3938
protected abstract Map<String, Object> getTypedExportedConstants();
4039

0 commit comments

Comments
 (0)