From 5c399a9f74f22c58c11f75abde32ac7dc269ccc0 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Mon, 10 Jun 2019 13:50:58 -0700 Subject: [PATCH] Workaround to avoid bridge access from ReactTextView for Venice 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 --- .../java/com/facebook/react/views/text/ReactTextView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java index b14e49e8bf9..feede92d6e8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java @@ -114,6 +114,12 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie 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();