Skip to content

Commit

Permalink
Workaround to avoid bridge access from ReactTextView for Venice
Browse files Browse the repository at this point in the history
Summary:
D14014668 introduced support for nesting views within Text on Android. Part of the implementation involved accessing the UIManagerModule from ReactTextView through context. This doesn't work in bridgeless RN because we have no UIManagerModule, and the ReactContext has no Catalyst instance. Trying to access the Catalyst instance from ReactContext throws an exception if it doesn't exist, so i'm just adding a simple check here to make sure the instance exists before proceeding.

This means that this feature won't work in bridgeless mode, but that's ok for now - eventually we want to change the way this works so that it doesn't rely on accessing views in Java, which is potentially unsafe (there's nothing to stop you from mutating the views, and cpp/js would never know about it).

Reviewed By: mdvacca

Differential Revision: D15703100

fbshipit-source-id: 0448d55b8345fc707a25210a505cb6ac520c708a
  • Loading branch information
Emily Janzer authored and facebook-github-bot committed Jun 10, 2019
1 parent bbeace1 commit 5c399a9
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ protected void onLayout(boolean changed,
return;
}

if (!getReactContext().hasCatalystInstance()) {
// In bridgeless mode there's no Catalyst instance; in that case, bail.
// TODO (T45503888): Figure out how to support nested views from JS or cpp.
return;
}

UIManagerModule uiManager = getReactContext().getNativeModule(UIManagerModule.class);

Spanned text = (Spanned) getText();
Expand Down

0 comments on commit 5c399a9

Please sign in to comment.