Skip to content

Commit 2f0c06d

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
setup gating for <TextOptimized /> (facebook#45031)
Summary: Pull Request resolved: facebook#45031 changelog: [internal] Reviewed By: rubennorte Differential Revision: D58672844 fbshipit-source-id: 2c99d3b66665c8dc0b796713b21d91211b469d81
1 parent d8739e1 commit 2f0c06d

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

packages/react-native/Libraries/Text/Text.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import type {PressEvent} from '../Types/CoreEventTypes';
1212
import type {TextProps} from './TextProps';
1313

14+
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
1415
import * as PressabilityDebug from '../Pressability/PressabilityDebug';
1516
import usePressability from '../Pressability/usePressability';
1617
import flattenStyle from '../StyleSheet/flattenStyle';
@@ -337,4 +338,8 @@ const verticalAlignToTextAlignVerticalMap = {
337338
middle: 'center',
338339
};
339340

340-
module.exports = Text;
341+
module.exports = (
342+
ReactNativeFeatureFlags.shouldUseOptimizedText()
343+
? require('./TextOptimized')
344+
: Text
345+
) as typeof Text;

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8048,7 +8048,7 @@ exports[`public API should not change unintentionally Libraries/Text/Text.js 1`]
80488048
TextProps,
80498049
React.ElementRef<typeof NativeText | typeof NativeVirtualText>,
80508050
>;
8051-
declare module.exports: Text;
8051+
declare module.exports: typeof Text;
80528052
"
80538053
`;
80548054

packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ const definitions: FeatureFlagDefinitions = {
187187
description:
188188
'Enables use of AnimatedObject for animating transform values.',
189189
},
190+
shouldUseOptimizedText: {
191+
defaultValue: false,
192+
description: 'Use optimized version of <Text /> component.',
193+
},
190194
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: {
191195
defaultValue: false,
192196
description:

packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<edd8917cdda9c37bbe84d036f62a36ba>>
7+
* @generated SignedSource<<522f11a571457cb932f451cf81bd384a>>
88
* @flow strict-local
99
*/
1010

@@ -32,6 +32,7 @@ export type ReactNativeFeatureFlagsJsOnly = {
3232
enableAccessToHostTreeInFabric: Getter<boolean>,
3333
isLayoutAnimationEnabled: Getter<boolean>,
3434
shouldUseAnimatedObjectForTransform: Getter<boolean>,
35+
shouldUseOptimizedText: Getter<boolean>,
3536
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter<boolean>,
3637
shouldUseSetNativePropsInFabric: Getter<boolean>,
3738
};
@@ -97,6 +98,11 @@ export const isLayoutAnimationEnabled: Getter<boolean> = createJavaScriptFlagGet
9798
*/
9899
export const shouldUseAnimatedObjectForTransform: Getter<boolean> = createJavaScriptFlagGetter('shouldUseAnimatedObjectForTransform', false);
99100

101+
/**
102+
* Use optimized version of <Text /> component.
103+
*/
104+
export const shouldUseOptimizedText: Getter<boolean> = createJavaScriptFlagGetter('shouldUseOptimizedText', false);
105+
100106
/**
101107
* removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android
102108
*/

0 commit comments

Comments
 (0)