From 758a3db449d770214883ba8d15da4856ca997bff Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Tue, 6 Jan 2026 20:37:34 -0800 Subject: [PATCH] Fling: Cleanup `enableVirtualViewExperimental` Feature Flag (#55065) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55065 Cleans up the `enableVirtualViewExperimental` feature flag, so that only the experimental one is ever used. This does not delete the original implementation or rename the experimental one. I'll do those separately as follow-ups. Changelog: [Internal] Reviewed By: lunaleaps Differential Revision: D90193651 fbshipit-source-id: e64a40b8ed49e4420370da300f03a8576a49321d --- .../ReactNativeFeatureFlags.config.js | 10 ------ .../components/virtualview/VirtualView.js | 10 ++---- .../VirtualViewExperimentalNativeComponent.js | 13 ++++---- .../__tests__/VirtualView-itest.js | 33 +++++++++++-------- .../featureflags/ReactNativeFeatureFlags.js | 8 +---- 5 files changed, 29 insertions(+), 45 deletions(-) diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 3ad588a7d6a..bb571572fec 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -1011,16 +1011,6 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, - enableVirtualViewExperimental: { - defaultValue: false, - metadata: { - dateAdded: '2025-08-29', - description: 'Enables the experimental version of `VirtualView`.', - expectedReleaseValue: true, - purpose: 'experimentation', - }, - ossReleaseStage: 'none', - }, fixVirtualizeListCollapseWindowSize: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/components/virtualview/VirtualView.js b/packages/react-native/src/private/components/virtualview/VirtualView.js index 245d2510a6f..a445cb2a3f7 100644 --- a/packages/react-native/src/private/components/virtualview/VirtualView.js +++ b/packages/react-native/src/private/components/virtualview/VirtualView.js @@ -11,13 +11,12 @@ import type {ViewStyleProp} from '../../../../Libraries/StyleSheet/StyleSheet'; import type {NativeSyntheticEvent} from '../../../../Libraries/Types/CoreEventTypes'; import type {HostInstance} from '../../types/HostInstance'; -import type {NativeModeChangeEvent} from './VirtualViewNativeComponent'; +import type {NativeModeChangeEvent} from './VirtualViewExperimentalNativeComponent'; import StyleSheet from '../../../../Libraries/StyleSheet/StyleSheet'; import * as ReactNativeFeatureFlags from '../../featureflags/ReactNativeFeatureFlags'; import {useVirtualViewLogging} from './logger/VirtualViewLogger'; -import VirtualViewExperimentalNativeComponent from './VirtualViewExperimentalNativeComponent'; -import VirtualViewClassicNativeComponent from './VirtualViewNativeComponent'; +import VirtualViewNativeComponent from './VirtualViewExperimentalNativeComponent'; import nullthrows from 'nullthrows'; import * as React from 'react'; // $FlowFixMe[missing-export] @@ -51,11 +50,6 @@ export type ModeChangeEvent = Readonly<{ target: HostInstance, }>; -const VirtualViewNativeComponent: typeof VirtualViewClassicNativeComponent = - ReactNativeFeatureFlags.enableVirtualViewExperimental() - ? VirtualViewExperimentalNativeComponent - : VirtualViewClassicNativeComponent; - type VirtualViewComponent = component( children?: React.Node, hiddenStyle?: (targetRect: Rect) => ViewStyleProp, diff --git a/packages/react-native/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js b/packages/react-native/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js index eaa20fd80c3..c640b5a0c5c 100644 --- a/packages/react-native/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +++ b/packages/react-native/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js @@ -67,6 +67,12 @@ type VirtualViewExperimentalNativeProps = Readonly<{ */ initialHidden?: boolean, + /** + * This was needed to get VirtualViewManagerDelegate to set this property. + * TODO: Investigate why spread ViewProps doesn't call setter + */ + removeClippedSubviews?: boolean, + /** * Render state of children. * @@ -79,18 +85,13 @@ type VirtualViewExperimentalNativeProps = Readonly<{ */ renderState: Int32, - /** - * This was needed to get VirtualViewManagerDelegate to set this property. - * TODO: Investigate why spread ViewProps doesn't call setter - */ - removeClippedSubviews?: boolean, - /** * See `NativeModeChangeEvent`. */ onModeChange?: ?DirectEventHandler, }>; +// TODO: Rename to eliminate "Experimental" suffix in the name. export default codegenNativeComponent( 'VirtualViewExperimental', { diff --git a/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js b/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js index 7871887d7c0..555016e048e 100644 --- a/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js +++ b/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js @@ -11,7 +11,7 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import type {Rect} from '../VirtualView'; -import type {NativeModeChangeEvent} from '../VirtualViewNativeComponent'; +import type {NativeModeChangeEvent} from '../VirtualViewExperimentalNativeComponent'; import ensureInstance from '../../../__tests__/utilities/ensureInstance'; import isUnreachable from '../../../__tests__/utilities/isUnreachable'; @@ -43,16 +43,16 @@ describe('mode changes', () => { expect(_logs.states).toHaveLength(1); expect(root.getRenderedOutput({props: []}).toJSX()).toEqual( - + Child - , + , ); dispatchModeChangeEvent(viewRef.current, VirtualViewMode.Hidden); expect(_logs.states).toHaveLength(2); expect(root.getRenderedOutput({props: []}).toJSX()).toEqual( - , + , ); }); @@ -72,16 +72,16 @@ describe('mode changes', () => { expect(_logs.states).toHaveLength(2); expect(root.getRenderedOutput({props: []}).toJSX()).toEqual( - , + , ); dispatchModeChangeEvent(viewRef.current, VirtualViewMode.Visible); expect(_logs.states).toHaveLength(3); expect(root.getRenderedOutput({props: []}).toJSX()).toEqual( - + Child - , + , ); }); @@ -101,9 +101,9 @@ describe('mode changes', () => { expect(_logs.states).toHaveLength(1); expect(root.getRenderedOutput({props: []}).toJSX()).toEqual( - + Child - , + , ); dispatchModeChangeEvent(viewRef.current, VirtualViewMode.Visible); @@ -111,9 +111,9 @@ describe('mode changes', () => { // Expects `VirtualView` does not undergo a state update. expect(_logs.states).toHaveLength(1); expect(root.getRenderedOutput({props: []}).toJSX()).toEqual( - + Child - , + , ); }); }); @@ -128,7 +128,7 @@ describe('styles', () => { expect( root.getRenderedOutput({props: ['minHeight', 'minWidth']}).toJSX(), - ).toEqual(); + ).toEqual(); }); test('does not set styles when prerendered', () => { @@ -143,7 +143,7 @@ describe('styles', () => { expect( root.getRenderedOutput({props: ['minHeight', 'minWidth']}).toJSX(), - ).toEqual(); + ).toEqual(); }); test('sets styles when hidden', () => { @@ -158,7 +158,12 @@ describe('styles', () => { expect( root.getRenderedOutput({props: ['minHeight', 'minWidth']}).toJSX(), - ).toEqual(); + ).toEqual( + , + ); }); }); diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index c66c199c099..f7c868b13b5 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<> + * @generated SignedSource<> * @flow strict * @noformat */ @@ -33,7 +33,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{ animatedShouldUseSingleOp: Getter, deferFlatListFocusChangeRenderUpdate: Getter, disableMaintainVisibleContentPosition: Getter, - enableVirtualViewExperimental: Getter, fixVirtualizeListCollapseWindowSize: Getter, isLayoutAnimationEnabled: Getter, reduceDefaultPropsInImage: Getter, @@ -163,11 +162,6 @@ export const deferFlatListFocusChangeRenderUpdate: Getter = createJavaS */ export const disableMaintainVisibleContentPosition: Getter = createJavaScriptFlagGetter('disableMaintainVisibleContentPosition', false); -/** - * Enables the experimental version of `VirtualView`. - */ -export const enableVirtualViewExperimental: Getter = createJavaScriptFlagGetter('enableVirtualViewExperimental', false); - /** * Fixing an edge case where the current window size is not properly calculated with fast scrolling. Window size collapsed to 1 element even if windowSize more than the current amount of elements */