From e9e0fbc0fd7ad94e258fb295be05e7ff691574ed Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Fri, 2 Feb 2024 09:34:13 -0800 Subject: [PATCH] RNTester - Legacy component example: do not convert commands to string (#42822) Summary: The conversion to string was introduced in D45043929. It was supposed to fix command execution for `MyLegacyNativeComponent` in RNTester on Android/Old Architecture. At the same time it introduced a regression on iOS, since we have [different code path](https://www.internalfb.com/code/fbsource/[ffee789cab9514c0a15b8a63869cbfdf4e534a56]/xplat/js/react-native-github/packages/react-native/React/Modules/RCTUIManager.m?lines=1088-1092) for string commands in iOS, where we expect command name, and not command number converted to string. I tried to remove that conversion, did local tests, and saw no issues with executing commands on Android. Looks like the underlying issue has been fixed in some other way. So let's just remove those conversions. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D53123956 --- .../js/MyLegacyViewNativeComponent.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/rn-tester/NativeComponentExample/js/MyLegacyViewNativeComponent.js b/packages/rn-tester/NativeComponentExample/js/MyLegacyViewNativeComponent.js index d4c7d33e0c9067..f4988f7880974e 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyLegacyViewNativeComponent.js +++ b/packages/rn-tester/NativeComponentExample/js/MyLegacyViewNativeComponent.js @@ -45,9 +45,8 @@ export function callNativeMethodToChangeBackgroundColor( } UIManager.dispatchViewManagerCommand( ReactNative.findNodeHandle(viewRef), - UIManager.getViewManagerConfig( - 'RNTMyLegacyNativeView', - ).Commands.changeBackgroundColor.toString(), + UIManager.getViewManagerConfig('RNTMyLegacyNativeView').Commands + .changeBackgroundColor, [color], ); } @@ -62,9 +61,8 @@ export function callNativeMethodToAddOverlays( } UIManager.dispatchViewManagerCommand( ReactNative.findNodeHandle(viewRef), - UIManager.getViewManagerConfig( - 'RNTMyLegacyNativeView', - ).Commands.addOverlays.toString(), + UIManager.getViewManagerConfig('RNTMyLegacyNativeView').Commands + .addOverlays, [overlayColors], ); } @@ -78,9 +76,8 @@ export function callNativeMethodToRemoveOverlays( } UIManager.dispatchViewManagerCommand( ReactNative.findNodeHandle(viewRef), - UIManager.getViewManagerConfig( - 'RNTMyLegacyNativeView', - ).Commands.removeOverlays.toString(), + UIManager.getViewManagerConfig('RNTMyLegacyNativeView').Commands + .removeOverlays, [], ); }