Skip to content

Commit 26119a1

Browse files
dmytrorykunShevO27
authored andcommitted
Enable native view configs in bridgeless mode in OSS (facebook#39476)
Summary: Pull Request resolved: facebook#39476 This diff enables native view config interop layer in bridgeless mode by default for OSS. It also removes redundant `enableNativeViewConfigsInBridgelessMode` JS feature flag. Changelog: [General][Added] - Native view config interop layer enabled in bridgeless mode. Reviewed By: luluwu2032 Differential Revision: D49318325 fbshipit-source-id: ea2e38b2ea10637b578d98e38d97eed923498fb3
1 parent f1d9b12 commit 26119a1

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8787

8888
if (enableBridgeless) {
8989
#if RCT_NEW_ARCH_ENABLED
90+
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
91+
RCTSetUseNativeViewConfigsInBridgelessMode([self fabricEnabled]);
9092
[self createReactHost];
9193
[self unstable_registerLegacyComponents];
9294
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;

packages/react-native/Libraries/ReactNative/BridgelessUIManager.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import type {RootTag} from '../Types/RootTagTypes';
1414

1515
import {unstable_hasComponent} from '../NativeComponent/NativeComponentRegistryUnstable';
16-
import ReactNativeFeatureFlags from './ReactNativeFeatureFlags';
1716

1817
let cachedConstants = null;
1918

@@ -22,6 +21,10 @@ const errorMessageForMethod = (methodName: string): string =>
2221
methodName +
2322
"' is not available in the new React Native architecture.";
2423

24+
function nativeViewConfigsInBridgelessModeEnabled(): boolean {
25+
return global.RN$LegacyInterop_UIManager_getConstants !== undefined;
26+
}
27+
2528
function getCachedConstants(): Object {
2629
if (!cachedConstants) {
2730
cachedConstants = global.RN$LegacyInterop_UIManager_getConstants();
@@ -31,7 +34,7 @@ function getCachedConstants(): Object {
3134

3235
const UIManagerJS: {[string]: $FlowFixMe} = {
3336
getViewManagerConfig: (viewManagerName: string): mixed => {
34-
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
37+
if (nativeViewConfigsInBridgelessModeEnabled()) {
3538
return getCachedConstants()[viewManagerName];
3639
} else {
3740
console.error(
@@ -46,7 +49,7 @@ const UIManagerJS: {[string]: $FlowFixMe} = {
4649
return unstable_hasComponent(viewManagerName);
4750
},
4851
getConstants: (): Object => {
49-
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
52+
if (nativeViewConfigsInBridgelessModeEnabled()) {
5053
return getCachedConstants();
5154
} else {
5255
console.error(errorMessageForMethod('getConstants'));
@@ -179,7 +182,7 @@ const UIManagerJS: {[string]: $FlowFixMe} = {
179182
console.error(errorMessageForMethod('dismissPopupMenu')),
180183
};
181184

182-
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
185+
if (nativeViewConfigsInBridgelessModeEnabled()) {
183186
Object.keys(getCachedConstants()).forEach(viewConfigName => {
184187
UIManagerJS[viewConfigName] = getCachedConstants()[viewConfigName];
185188
});

packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ export type FeatureFlags = {|
5454
* Enables use of setNativeProps in JS driven animations.
5555
*/
5656
shouldUseSetNativePropsInFabric: () => boolean,
57-
/**
58-
* Enables native view configs in brdgeless mode.
59-
*/
60-
enableNativeViewConfigsInBridgelessMode: () => boolean,
6157
/**
6258
* Enables a hotfix for forcing materialization of views with elevation set.
6359
*/
@@ -74,7 +70,6 @@ const ReactNativeFeatureFlags: FeatureFlags = {
7470
enableAccessToHostTreeInFabric: () => false,
7571
shouldUseAnimatedObjectForTransform: () => false,
7672
shouldUseSetNativePropsInFabric: () => false,
77-
enableNativeViewConfigsInBridgelessMode: () => false,
7873
shouldForceUnflattenForElevation: () => false,
7974
};
8075

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object DefaultNewArchitectureEntryPoint {
3434
ReactFeatureFlags.enableFabricRenderer = fabricEnabled
3535
ReactFeatureFlags.unstable_useFabricInterop = fabricEnabled
3636
ReactFeatureFlags.enableBridgelessArchitecture = bridgelessEnabled
37+
ReactFeatureFlags.useNativeViewConfigsInBridgelessMode = fabricEnabled && bridgelessEnabled
3738

3839
this.privateFabricEnabled = fabricEnabled
3940
this.privateTurboModulesEnabled = turboModulesEnabled

0 commit comments

Comments
 (0)