From 9c4601abec980023cbc42d6fdd162f7c0fdf8a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 30 Oct 2025 08:37:04 -0700 Subject: [PATCH] Clean up feature flag "enableAccessToHostTreeInFabric" (#54322) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54322 Changelog: [internal] This just cleans up the feature flag, which is set to `true` by default and it's been enabled in `stable` already. Reviewed By: lunaleaps, yungsters Differential Revision: D85782127 fbshipit-source-id: 0a6174708066cfe597b4c6dbc8bb33829c6155e9 --- .../ReactFabricPublicInstance.js | 43 ++++--------------- .../ReactFabricPublicInstance-itest.js | 9 +--- .../ReactNativeFeatureFlags.config.js | 10 ----- .../featureflags/ReactNativeFeatureFlags.js | 8 +--- .../private/featureflags/__docs__/README.md | 1 - .../__tests__/ReactNativeElement-itest.js | 2 +- .../dom/nodes/__tests__/ReadOnlyText-itest.js | 2 +- .../runner/getFantomTestConfigs.js | 4 +- 8 files changed, 14 insertions(+), 65 deletions(-) diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js index aded8e28178..ea904e48e50 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js @@ -26,13 +26,10 @@ import type { import type {RootTag} from '../RootTag'; import type ReactFabricHostComponentT from './ReactFabricHostComponent'; -import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags'; - export opaque type PublicRootInstance = mixed; // Lazy loaded to avoid evaluating the module when using the legacy renderer. let ReactNativeDocumentModuleObject: ?ReactNativeDocumentModuleT; -let ReactFabricHostComponentClass: Class; let ReactNativeElementClass: Class; let ReadOnlyTextClass: Class; let RendererProxy: RendererProxyT; @@ -54,14 +51,6 @@ function getReactNativeElementClass(): Class { return ReactNativeElementClass; } -function getReactFabricHostComponentClass(): Class { - if (ReactFabricHostComponentClass == null) { - ReactFabricHostComponentClass = - require('./ReactFabricHostComponent').default; - } - return ReactFabricHostComponentClass; -} - function getReadOnlyTextClass(): Class { if (ReadOnlyTextClass == null) { ReadOnlyTextClass = @@ -71,15 +60,10 @@ function getReadOnlyTextClass(): Class { } export function createPublicRootInstance(rootTag: RootTag): PublicRootInstance { - if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) { - const ReactNativeDocumentModule = getReactNativeDocumentModule(); - - // $FlowExpectedError[incompatible-return] - return ReactNativeDocumentModule.createReactNativeDocument(rootTag); - } + const ReactNativeDocumentModule = getReactNativeDocumentModule(); // $FlowExpectedError[incompatible-return] - return null; + return ReactNativeDocumentModule.createReactNativeDocument(rootTag); } export function createPublicInstance( @@ -88,22 +72,13 @@ export function createPublicInstance( internalInstanceHandle: InternalInstanceHandle, ownerDocument: ReactNativeDocumentT, ): ReactFabricHostComponentT | ReactNativeElementT { - if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) { - const ReactNativeElement = getReactNativeElementClass(); - return new ReactNativeElement( - tag, - viewConfig, - internalInstanceHandle, - ownerDocument, - ); - } else { - const ReactFabricHostComponent = getReactFabricHostComponentClass(); - return new ReactFabricHostComponent( - tag, - viewConfig, - internalInstanceHandle, - ); - } + const ReactNativeElement = getReactNativeElementClass(); + return new ReactNativeElement( + tag, + viewConfig, + internalInstanceHandle, + ownerDocument, + ); } export function createPublicTextInstance( diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/ReactFabricPublicInstance-itest.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/ReactFabricPublicInstance-itest.js index dcd1cd1df25..223e23836e4 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/ReactFabricPublicInstance-itest.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/ReactFabricPublicInstance-itest.js @@ -6,7 +6,6 @@ * * @flow strict-local * @format - * @fantom_flags enableAccessToHostTreeInFabric:* */ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; @@ -17,12 +16,10 @@ import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactN import TextInput from '../../../Components/TextInput/TextInput'; import TextInputState from '../../../Components/TextInput/TextInputState'; import View from '../../../Components/View/View'; -import ReactFabricHostComponent from '../ReactFabricHostComponent'; import * as Fantom from '@react-native/fantom'; import nullthrows from 'nullthrows'; import * as React from 'react'; import {createRef} from 'react'; -import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags'; // TODO: move these tests to the test file for `ReactNativeElement` when the legacy implementation is removed. describe('ReactFabricPublicInstance', () => { @@ -36,11 +33,7 @@ describe('ReactFabricPublicInstance', () => { const node = nullthrows(nodeRef.current); - expect(node).toBeInstanceOf( - ReactNativeFeatureFlags.enableAccessToHostTreeInFabric() - ? ReactNativeElement - : ReactFabricHostComponent, - ); + expect(node).toBeInstanceOf(ReactNativeElement); }); describe('blur', () => { diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 16393e9c0ab..71cec3c55a4 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -968,16 +968,6 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, - enableAccessToHostTreeInFabric: { - defaultValue: true, - metadata: { - description: - 'Enables access to the host tree in Fabric using DOM-compatible APIs.', - expectedReleaseValue: true, - purpose: 'release', - }, - ossReleaseStage: 'stable', - }, enableVirtualViewExperimental: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 847d332746b..10db4909c19 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<7edda733c47c5e6db0287b8b6325cdfb>> + * @generated SignedSource<> * @flow strict * @noformat */ @@ -34,7 +34,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{ configurePressabilityDuringInsertion: Getter, deferFlatListFocusChangeRenderUpdate: Getter, disableMaintainVisibleContentPosition: Getter, - enableAccessToHostTreeInFabric: Getter, enableVirtualViewExperimental: Getter, fixVirtualizeListCollapseWindowSize: Getter, isLayoutAnimationEnabled: Getter, @@ -164,11 +163,6 @@ export const deferFlatListFocusChangeRenderUpdate: Getter = createJavaS */ export const disableMaintainVisibleContentPosition: Getter = createJavaScriptFlagGetter('disableMaintainVisibleContentPosition', false); -/** - * Enables access to the host tree in Fabric using DOM-compatible APIs. - */ -export const enableAccessToHostTreeInFabric: Getter = createJavaScriptFlagGetter('enableAccessToHostTreeInFabric', true); - /** * Enables the experimental version of `VirtualView`. */ diff --git a/packages/react-native/src/private/featureflags/__docs__/README.md b/packages/react-native/src/private/featureflags/__docs__/README.md index f64c566f944..36ca6c00705 100644 --- a/packages/react-native/src/private/featureflags/__docs__/README.md +++ b/packages/react-native/src/private/featureflags/__docs__/README.md @@ -163,7 +163,6 @@ Which would print something like: ├────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────┼──────────────┤ │ enableFabricLogs │ 'This feature flag enables logs for Fabric.' │ '🔨' │ undefined │ │ jsOnlyTestFlag │ 'JS-only flag for testing. Do NOT modify.' │ '🔨' │ undefined │ -│ enableAccessToHostTreeInFabric │ 'Enables access to the host tree in Fabric using DOM-compatible APIs.' │ '🚀' │ undefined │ │ enableBridgelessArchitecture │ 'Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the fo...' │ '🚀' │ undefined │ │ useTurboModules │ 'When enabled, NativeModules will be executed by using the TurboModule system' │ '🚀' │ undefined │ │ animatedShouldDebounceQueueFlush │ 'Enables an experimental flush-queue debouncing in Animated.js.' │ '🧪' │ '2024-02-05' │ diff --git a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js index 9d4343168f9..4e0cecb0822 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js +++ b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js @@ -34,7 +34,7 @@ function ensureReactNativeElement(value: mixed): ReactNativeElement { /* eslint-disable no-bitwise */ describe('ReactNativeElement', () => { - it('should be used to create public instances when the `enableAccessToHostTreeInFabric` feature flag is enabled', () => { + it('should be used to create public instances', () => { const ref = createRef(); const root = Fantom.createRoot(); diff --git a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js index e5647596472..8925e5040c9 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js +++ b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js @@ -35,7 +35,7 @@ function ensureReactNativeElement(value: mixed): ReactNativeElement { } describe('ReadOnlyText', () => { - it('should be used to create public text instances when the `enableAccessToHostTreeInFabric` feature flag is enabled', () => { + it('should be used to create public text instances', () => { const parentNodeRef = createRef(); const root = Fantom.createRoot(); diff --git a/private/react-native-fantom/runner/getFantomTestConfigs.js b/private/react-native-fantom/runner/getFantomTestConfigs.js index 5c72f1ef1d9..a8fbaa3a62e 100644 --- a/private/react-native-fantom/runner/getFantomTestConfigs.js +++ b/private/react-native-fantom/runner/getFantomTestConfigs.js @@ -63,9 +63,7 @@ export const DEFAULT_HERMES_VARIANT: HermesVariant = HermesVariant.Hermes; export const DEFAULT_FEATURE_FLAGS: FantomTestConfigFeatureFlags = { common: {}, - jsOnly: { - enableAccessToHostTreeInFabric: true, - }, + jsOnly: {}, reactInternal: {}, };