mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook Github Bot
parent
37ff892e24
commit
636f48de89
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user