Skip to content

Commit 5b56e6d

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Enabale native view configs in bridgeless mode in OSS (#39476)
Summary: Pull Request resolved: #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. Differential Revision: D49318325 fbshipit-source-id: f07e691a16d5c65032ad1002faecf1d1afa219c0
1 parent 60bd497 commit 5b56e6d

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

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

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

8888
if (enableBridgeless) {
8989
#if RCT_NEW_ARCH_ENABLED
90+
RCTSetUseNativeViewConfigsInBridgelessMode(YES);
9091
[self createReactHost];
9192
[self unstable_registerLegacyComponents];
9293
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;

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

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

1515
import {unstable_hasComponent} from '../NativeComponent/NativeComponentRegistryUnstable';
1616
import NativeUIManager from './NativeUIManager';
17-
import ReactNativeFeatureFlags from './ReactNativeFeatureFlags';
1817

1918
let cachedConstants = null;
2019

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

25+
function nativeViewConfigsInBridgelessModeEnabled(): boolean {
26+
return global.RN$LegacyInterop_UIManager_getConstants !== undefined;
27+
}
28+
2629
function getCachedConstants(): Object {
2730
if (!cachedConstants) {
2831
cachedConstants = global.RN$LegacyInterop_UIManager_getConstants();
@@ -36,7 +39,7 @@ function getCachedConstants(): Object {
3639
const UIManagerJS = {
3740
...NativeUIManager,
3841
getViewManagerConfig: (viewManagerName: string): mixed => {
39-
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
42+
if (nativeViewConfigsInBridgelessModeEnabled()) {
4043
return getCachedConstants()[viewManagerName];
4144
} else {
4245
console.error(
@@ -51,7 +54,7 @@ const UIManagerJS = {
5154
return unstable_hasComponent(viewManagerName);
5255
},
5356
getConstants: (): Object => {
54-
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
57+
if (nativeViewConfigsInBridgelessModeEnabled()) {
5558
return getCachedConstants();
5659
} else {
5760
console.error(errorMessageForMethod('getConstants'));

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ object DefaultNewArchitectureEntryPoint {
3434
ReactFeatureFlags.enableFabricRenderer = fabricEnabled
3535
ReactFeatureFlags.unstable_useFabricInterop = fabricEnabled
3636
ReactFeatureFlags.enableBridgelessArchitecture = bridgelessEnabled
37+
if (bridgelessEnabled) {
38+
ReactFeatureFlags.useNativeViewConfigsInBridgelessMode = true
39+
}
3740

3841
this.privateFabricEnabled = fabricEnabled
3942
this.privateTurboModulesEnabled = turboModulesEnabled

0 commit comments

Comments
 (0)