Skip to content

Commit

Permalink
Enabale native view configs in bridgeless mode in OSS (#39476)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Sep 18, 2023
1 parent 60bd497 commit 5b56e6d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type {RootTag} from '../Types/RootTagTypes';

import {unstable_hasComponent} from '../NativeComponent/NativeComponentRegistryUnstable';
import NativeUIManager from './NativeUIManager';
import ReactNativeFeatureFlags from './ReactNativeFeatureFlags';

let cachedConstants = null;

Expand All @@ -23,6 +22,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();
Expand All @@ -36,7 +39,7 @@ function getCachedConstants(): Object {
const UIManagerJS = {
...NativeUIManager,
getViewManagerConfig: (viewManagerName: string): mixed => {
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
if (nativeViewConfigsInBridgelessModeEnabled()) {
return getCachedConstants()[viewManagerName];
} else {
console.error(
Expand All @@ -51,7 +54,7 @@ const UIManagerJS = {
return unstable_hasComponent(viewManagerName);
},
getConstants: (): Object => {
if (ReactNativeFeatureFlags.enableNativeViewConfigsInBridgelessMode()) {
if (nativeViewConfigsInBridgelessModeEnabled()) {
return getCachedConstants();
} else {
console.error(errorMessageForMethod('getConstants'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -74,7 +70,6 @@ const ReactNativeFeatureFlags: FeatureFlags = {
enableAccessToHostTreeInFabric: () => false,
shouldUseAnimatedObjectForTransform: () => false,
shouldUseSetNativePropsInFabric: () => false,
enableNativeViewConfigsInBridgelessMode: () => false,
shouldForceUnflattenForElevation: () => false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b56e6d

Please sign in to comment.