Ensure UIManagerHelper does not access UIManagerModule (#50159)

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

Ensure UIManagerHelper does not access UIManagerModule

changelog: [internal] internal

Reviewed By: cortinico, alanleedev

Differential Revision: D70742205

fbshipit-source-id: f7eabfb7d28b4debc667a9b0cfd55741b373380b
This commit is contained in:
David Vacca
2025-03-20 13:08:29 -07:00
committed by Facebook GitHub Bot
parent 73b220f483
commit 4f8d215d8e
@@ -22,6 +22,8 @@ import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.EventDispatcherProvider;
@@ -69,6 +71,14 @@ public class UIManagerHelper {
return uiManager;
}
// The following code is compiled-out when `context.isBridgeless() == true &&
// ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE == true ` because:
// - BridgelessReactContext.isBridgeless() is set to true statically
// - BridgeReactContext is compiled-out when UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE == true
//
// To detect a potential regression we add the following assertion ERROR
LegacyArchitectureLogger.assertWhenLegacyArchitectureMinifyingEnabled(
"UIManagerHelper.getUIManager(context, uiManagerType)", LegacyArchitectureLogLevel.ERROR);
if (!context.hasCatalystInstance()) {
ReactSoftExceptionLogger.logSoftException(
TAG,