From 6386988de1a55d082ffc8162571398ca8e3bafd5 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 26 Mar 2024 07:15:29 -0700 Subject: [PATCH] Introduce BridgeReactContext < ReactApplicationContext (#43624) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43624 Eventually, we will move all bridge methods to BridgeReactContext. Long-term, ReactApplicationContext and ReactContext will become abstract. And these two contexts will only contain methods common to both modes. Changelog: [Android][Added] Introduce BridgeReactContext Reviewed By: cortinico Differential Revision: D55218592 fbshipit-source-id: 731d4940d492a1ed3f855c9a181d2a6f9eeb9623 --- .../ReactAndroid/api/ReactAndroid.api | 4 ++++ .../react/bridge/BridgeReactContext.kt | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeReactContext.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 8d081e9d006..37b12bcdee0 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -532,6 +532,10 @@ public abstract class com/facebook/react/bridge/BaseJavaModule : com/facebook/re public fun invalidate ()V } +public final class com/facebook/react/bridge/BridgeReactContext : com/facebook/react/bridge/ReactApplicationContext { + public fun (Landroid/content/Context;)V +} + public abstract interface class com/facebook/react/bridge/Callback { public abstract fun invoke ([Ljava/lang/Object;)V } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeReactContext.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeReactContext.kt new file mode 100644 index 00000000000..7ca3ef1cd9d --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeReactContext.kt @@ -0,0 +1,20 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.bridge + +import android.content.Context +import com.facebook.react.common.annotations.DeprecatedInNewArchitecture + +/** + * This is the bridge-specific concrete subclass of ReactContext. ReactContext has many methods that + * delegate to the react instance. This subclass will implement those methods, by delegating to the + * CatalystInstance. If you need to create a ReactContext within an "bridge context", please create + * BridgeReactContext. + */ +@DeprecatedInNewArchitecture +class BridgeReactContext(base: Context) : ReactApplicationContext(base) {}