diff --git a/packages/react-native/Libraries/Lists/FlatList.js b/packages/react-native/Libraries/Lists/FlatList.js index 1b2ee1707c10..3d267cb95988 100644 --- a/packages/react-native/Libraries/Lists/FlatList.js +++ b/packages/react-native/Libraries/Lists/FlatList.js @@ -17,6 +17,7 @@ import type { ViewToken, } from '@react-native/virtualized-lists'; +import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags'; import {type ScrollResponderType} from '../Components/ScrollView/ScrollView'; import { VirtualizedList, @@ -158,7 +159,11 @@ type OptionalProps = {| // removeClippedSubviewsOrDefault(this.props.removeClippedSubviews) function removeClippedSubviewsOrDefault(removeClippedSubviews: ?boolean) { - return removeClippedSubviews ?? Platform.OS === 'android'; + if (ReactNativeFeatureFlags.shouldUseRemoveClippedSubviewsAsDefaultOnIOS()) { + return removeClippedSubviews ?? true; + } else { + return removeClippedSubviews ?? Platform.OS === 'android'; + } } // numColumnsOrDefault(this.props.numColumns) diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json index 48279fa0a767..8ec639c82979 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json @@ -53,6 +53,10 @@ "shouldUseSetNativePropsInFabric": { "description": "Enables use of setNativeProps in JS driven animations.", "defaultValue": true + }, + "shouldUseRemoveClippedSubviewsAsDefaultOnIOS": { + "description": "removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android", + "defaultValue": false } } } diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 858d4a00ba0f..3f73624c7ef8 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-local */ @@ -33,6 +33,7 @@ export type ReactNativeFeatureFlagsJsOnly = { enableAccessToHostTreeInFabric: Getter, shouldUseAnimatedObjectForTransform: Getter, shouldUseSetNativePropsInFabric: Getter, + shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter, }; export type ReactNativeFeatureFlagsJsOnlyOverrides = Partial; @@ -82,6 +83,11 @@ export const shouldUseAnimatedObjectForTransform: Getter = createJavaSc */ export const shouldUseSetNativePropsInFabric: Getter = createJavaScriptFlagGetter('shouldUseSetNativePropsInFabric', true); +/** + * removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android + */ +export const shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter = createJavaScriptFlagGetter('shouldUseRemoveClippedSubviewsAsDefaultOnIOS', false); + /** * Common flag for testing. Do NOT modify. */