From 6cf784fae77ea17a2a1483f5e8212d6202aaf06a Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Mon, 6 May 2019 15:41:17 -0700 Subject: [PATCH] Allow creating ThemedReactContext without CatalystInstance Summary: I'm not sure if this is a good idea. Right now FabricUIManager creates a ThemedReactContext in addRootView() using the RAC you pass in. If you pass in an RAC without a Catalyst instance, this will throw; this diff makes it so it'll throw the next time you try to actually try to access the CatalystInstance, instead. I don't know if we're really relying on this right now, but we need to be able to create a ThemedReactContext without a CatalystInstance for Venice (for now, until we actually go through and get rid of TRC's dependency on the CatalystInstance entirely - but that'll be a lot more work) Reviewed By: mdvacca Differential Revision: D15194220 fbshipit-source-id: 64689cbe79c84ae33fe16e3dc396e3c69ec8e20f --- .../java/com/facebook/react/uimanager/ThemedReactContext.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java index e061c1134..2ec10d0a2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java @@ -30,7 +30,9 @@ public class ThemedReactContext extends ReactContext { public ThemedReactContext(ReactApplicationContext reactApplicationContext, Context base) { super(base); - initializeWithInstance(reactApplicationContext.getCatalystInstance()); + if (reactApplicationContext.hasActiveCatalystInstance()) { + initializeWithInstance(reactApplicationContext.getCatalystInstance()); + } mReactApplicationContext = reactApplicationContext; }