Throw if getCatalystInstance() is executed when running on bridgless mode + legacy arch minification (#51112)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51112

Throw if getCatalystInstance() is executed when running on bridgless mode + legacy arch minification

This should be safe given that all the methods of BridgelessCatalystInstance throw exceptions

changelog: [internal] internal

Reviewed By: alanleedev

Differential Revision: D74200099

fbshipit-source-id: a888061250f19348a22895c3684aa2333280c916
This commit is contained in:
David Vacca authored and Facebook GitHub Bot committed 2025-05-05 23:53:10 -07:00
1 parent a02052d37f
commit 3ad0b8244a
1 file changed
+5
@@ -24,6 +24,7 @@ import com.facebook.react.bridge.UIManager
import com.facebook.react.bridge.WritableNativeArray
import com.facebook.react.common.annotations.FrameworkAPI
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.devsupport.interfaces.DevSupportManager
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
@@ -63,6 +64,10 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
override fun getFabricUIManager(): UIManager? = reactHost.uiManager
override fun getCatalystInstance(): CatalystInstance {
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
throw UnsupportedOperationException(
"CatalystInstance is not supported when Bridgeless mode is enabled.")
}
Log.w(
TAG,
"[WARNING] Bridgeless doesn't support CatalystInstance. Accessing an API that's not part of" +