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
This commit is contained in:
Rubén Norte authored and meta-codesync[bot] committed 2025-10-30 08:37:04 -07:00
1 parent beccee2164
commit 9c4601abec
8 files changed
+14 -65

No files matched your search

@@ -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<ReactFabricHostComponentT>;
let ReactNativeElementClass: Class<ReactNativeElementT>;
let ReadOnlyTextClass: Class<ReadOnlyTextT>;
let RendererProxy: RendererProxyT;
@@ -54,14 +51,6 @@ function getReactNativeElementClass(): Class<ReactNativeElementT> {
return ReactNativeElementClass;
}
function getReactFabricHostComponentClass(): Class<ReactFabricHostComponentT> {
if (ReactFabricHostComponentClass == null) {
ReactFabricHostComponentClass =
require('./ReactFabricHostComponent').default;
}
return ReactFabricHostComponentClass;
}
function getReadOnlyTextClass(): Class<ReadOnlyTextT> {
if (ReadOnlyTextClass == null) {
ReadOnlyTextClass =
@@ -71,15 +60,10 @@ function getReadOnlyTextClass(): Class<ReadOnlyTextT> {
}
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(
@@ -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', () => {
@@ -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: {
@@ -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<<f3aafc19ab1aa753684c933fef0d2dd2>>
* @flow strict
* @noformat
*/
@@ -34,7 +34,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
configurePressabilityDuringInsertion: Getter<boolean>,
deferFlatListFocusChangeRenderUpdate: Getter<boolean>,
disableMaintainVisibleContentPosition: Getter<boolean>,
enableAccessToHostTreeInFabric: Getter<boolean>,
enableVirtualViewExperimental: Getter<boolean>,
fixVirtualizeListCollapseWindowSize: Getter<boolean>,
isLayoutAnimationEnabled: Getter<boolean>,
@@ -164,11 +163,6 @@ export const deferFlatListFocusChangeRenderUpdate: Getter<boolean> = createJavaS
*/
export const disableMaintainVisibleContentPosition: Getter<boolean> = createJavaScriptFlagGetter('disableMaintainVisibleContentPosition', false);
/**
* Enables access to the host tree in Fabric using DOM-compatible APIs.
*/
export const enableAccessToHostTreeInFabric: Getter<boolean> = createJavaScriptFlagGetter('enableAccessToHostTreeInFabric', true);
/**
* Enables the experimental version of `VirtualView`.
*/
@@ -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' │
@@ -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<HostInstance>();
const root = Fantom.createRoot();
@@ -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<HostInstance>();
const root = Fantom.createRoot();
+1 -3
View File
@@ -63,9 +63,7 @@ export const DEFAULT_HERMES_VARIANT: HermesVariant = HermesVariant.Hermes;
export const DEFAULT_FEATURE_FLAGS: FantomTestConfigFeatureFlags = {
common: {},
jsOnly: {
enableAccessToHostTreeInFabric: true,
},
jsOnly: {},
reactInternal: {},
};