diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index d16b85ce9e979f..9896d5249912b3 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -87,6 +87,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( if (enableBridgeless) { #if RCT_NEW_ARCH_ENABLED + RCTSetUseNativeViewConfigsInBridgelessMode(YES); [self createReactHost]; [self unstable_registerLegacyComponents]; [RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self; diff --git a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js index 8b9a746815e5b4..d7f0efd654e162 100644 --- a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js +++ b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js @@ -13,7 +13,6 @@ import type {RootTag} from '../Types/RootTagTypes'; import {unstable_hasComponent} from '../NativeComponent/NativeComponentRegistryUnstable'; -import ReactNativeFeatureFlags from './ReactNativeFeatureFlags'; let cachedConstants = null; @@ -22,6 +21,10 @@ const errorMessageForMethod = (methodName: string): string => methodName + "' is not available in the new React Native architecture."; +function nativeViewConfigsInBridgelessModeEnabled(): boolean { + return global.RN$LegacyInterop_UIManager_getConstants !== undefined; +} + function getCachedConstants(): Object { if (!cachedConstants) { cachedConstants = global.RN$LegacyInterop_UIManager_getConstants(); @@ -31,7 +34,7 @@ function getCachedConstants(): Object { const UIManagerJS: {[string]: $FlowFixMe} = { getViewManagerConfig: (viewManagerName: string): mixed => { - if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) { + if (nativeViewConfigsInBridgelessModeEnabled()) { return getCachedConstants()[viewManagerName]; } else { console.error( @@ -46,7 +49,7 @@ const UIManagerJS: {[string]: $FlowFixMe} = { return unstable_hasComponent(viewManagerName); }, getConstants: (): Object => { - if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) { + if (nativeViewConfigsInBridgelessModeEnabled()) { return getCachedConstants(); } else { console.error(errorMessageForMethod('getConstants')); @@ -179,7 +182,7 @@ const UIManagerJS: {[string]: $FlowFixMe} = { console.error(errorMessageForMethod('dismissPopupMenu')), }; -if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) { +if (nativeViewConfigsInBridgelessModeEnabled()) { Object.keys(getCachedConstants()).forEach(viewConfigName => { UIManagerJS[viewConfigName] = getCachedConstants()[viewConfigName]; }); diff --git a/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js b/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js index 01a56fb5098b58..95d15e6e2f968c 100644 --- a/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js +++ b/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js @@ -54,10 +54,6 @@ export type FeatureFlags = {| * Enables use of setNativeProps in JS driven animations. */ shouldUseSetNativePropsInFabric: () => boolean, - /** - * Enables native view configs in brdgeless mode. - */ - enableNativeViewConfigsInBridgelessMode: () => boolean, /** * Enables a hotfix for forcing materialization of views with elevation set. */ @@ -74,7 +70,6 @@ const ReactNativeFeatureFlags: FeatureFlags = { enableAccessToHostTreeInFabric: () => false, shouldUseAnimatedObjectForTransform: () => false, shouldUseSetNativePropsInFabric: () => false, - enableNativeViewConfigsInBridgelessMode: () => false, shouldForceUnflattenForElevation: () => false, }; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt index e3aa9aebae05e4..9308a3cb440de8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt @@ -34,6 +34,9 @@ object DefaultNewArchitectureEntryPoint { ReactFeatureFlags.enableFabricRenderer = fabricEnabled ReactFeatureFlags.unstable_useFabricInterop = fabricEnabled ReactFeatureFlags.enableBridgelessArchitecture = bridgelessEnabled + if (bridgelessEnabled) { + ReactFeatureFlags.useNativeViewConfigsInBridgelessMode = true + } this.privateFabricEnabled = fabricEnabled this.privateTurboModulesEnabled = turboModulesEnabled