Skip to content

Commit

Permalink
Hide JS executor in Dev Menu when unimplemented
Browse files Browse the repository at this point in the history
Summary:
Fixes exception thrown when `getJavaScriptExecutorFactory()` is not implemented on bridgeless.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D47755422

fbshipit-source-id: 6feffa5e926fb7e04ac95d942f8a2b0303f3878b
  • Loading branch information
huntie authored and facebook-github-bot committed Jul 25, 2023
1 parent e64756a commit 390389d
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 390389d

Please sign in to comment.