diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index efd48a1ff43..ba673373e3c 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -43,7 +43,9 @@ const propSetterTemplate = ` const commandsTemplate = ` public void receiveCommand(::_INTERFACE_CLASSNAME_:: viewManager, T view, String commandName, ReadableArray args) { - ::_COMMAND_CASES_:: + switch (commandName) { + ::_COMMAND_CASES_:: + } } `; @@ -173,13 +175,13 @@ function generateCommandCasesString( const commandMethods = component.commands .map(command => { return `case "${command.name}": - viewManager.${toSafeJavaString( - command.name, - false, - )}(${getCommandArguments(command)}); - break;`; + viewManager.${toSafeJavaString( + command.name, + false, + )}(${getCommandArguments(command)}); + break;`; }) - .join('\n' + ' '); + .join('\n' + ' '); return commandMethods; } diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 2155770c410..6cb2a998962 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -168,12 +168,14 @@ public class CommandNativeComponentManagerDelegate viewManager, T view, String commandName, ReadableArray args) { - case \\"flashScrollIndicators\\": - viewManager.flashScrollIndicators(view); - break; - case \\"allTypes\\": - viewManager.allTypes(view, args.getInt(0), args.getFloat(1), args.getDouble(2), args.getString(3), args.getBoolean(4)); - break; + switch (commandName) { + case \\"flashScrollIndicators\\": + viewManager.flashScrollIndicators(view); + break; + case \\"allTypes\\": + viewManager.allTypes(view, args.getInt(0), args.getFloat(1), args.getDouble(2), args.getString(3), args.getBoolean(4)); + break; + } } } ", @@ -208,9 +210,11 @@ public class CommandNativeComponentManagerDelegate viewManager, T view, String commandName, ReadableArray args) { - case \\"hotspotUpdate\\": - viewManager.hotspotUpdate(view, args.getInt(0), args.getInt(1)); - break; + switch (commandName) { + case \\"hotspotUpdate\\": + viewManager.hotspotUpdate(view, args.getInt(0), args.getInt(1)); + break; + } } } ",