Skip to content

Commit

Permalink
Hide JS executor in Dev Menu when unimplemented (facebook#38622)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#38622

Fixes exception thrown when `getJavaScriptExecutorFactory()` is not implemented on bridgeless.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D47755422

fbshipit-source-id: 260b204703a4d16714d8d45071000a1c45d94fde
  • Loading branch information
huntie authored and facebook-github-bot committed Jul 25, 2023
1 parent e64756a commit 0446a16
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,16 +510,19 @@ public void onOptionSelected() {
title.setGravity(Gravity.CENTER);
title.setTextSize(16);
title.setTypeface(title.getTypeface(), Typeface.BOLD);
header.addView(title);

final TextView jsExecutorLabel = new TextView(context);
jsExecutorLabel.setText(
context.getString(R.string.catalyst_dev_menu_sub_header, getJSExecutorDescription()));
jsExecutorLabel.setPadding(0, 20, 0, 0);
jsExecutorLabel.setGravity(Gravity.CENTER);
jsExecutorLabel.setTextSize(14);
String jsExecutorDescription = getJSExecutorDescription();

header.addView(title);
header.addView(jsExecutorLabel);
if (jsExecutorDescription != null) {
final TextView jsExecutorLabel = new TextView(context);
jsExecutorLabel.setText(
context.getString(R.string.catalyst_dev_menu_sub_header, jsExecutorDescription));
jsExecutorLabel.setPadding(0, 20, 0, 0);
jsExecutorLabel.setGravity(Gravity.CENTER);
jsExecutorLabel.setTextSize(14);
header.addView(jsExecutorLabel);
}

mDevOptionsDialog =
new AlertDialog.Builder(context)
Expand All @@ -539,7 +542,11 @@ public void onOptionSelected() {
}

private String getJSExecutorDescription() {
return getReactInstanceDevHelper().getJavaScriptExecutorFactory().toString();
try {
return getReactInstanceDevHelper().getJavaScriptExecutorFactory().toString();
} catch (IllegalStateException e) {
return null;
}
}

/**
Expand Down

0 comments on commit 0446a16

Please sign in to comment.