From 636f48de89aaeddd6a3e5740c5bcd4649d39c909 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Tue, 17 Dec 2019 18:28:16 -0800 Subject: [PATCH] Check bridgeless mode in getReactApplicationContextIfActiveOrWarn Summary: We currently have a method in ReactContextBaseJavaModule that logs a warning if the native module is trying to access a ReactContext without an active Catalyst instance (because if you try to access it directly, it throws). For bridgeless mode, we never have a CatalystInstance, but it's safe to call certain methods on the context that would normally require one. For this case, let's just return the context when the context is in bridgeless mode. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D19133988 fbshipit-source-id: cae0bd397aa24d9ad416491cbc32676870cc70b0 --- .../com/facebook/react/bridge/ReactContextBaseJavaModule.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java index 00bf2fb6ff3..eb2111e4db3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java @@ -52,7 +52,8 @@ public abstract class ReactContextBaseJavaModule extends BaseJavaModule { */ @ThreadConfined(ANY) protected @Nullable final ReactApplicationContext getReactApplicationContextIfActiveOrWarn() { - if (mReactApplicationContext.hasActiveCatalystInstance()) { + if (mReactApplicationContext.hasActiveCatalystInstance() + || mReactApplicationContext.isBridgeless()) { return mReactApplicationContext; }