Skip to content

Commit

Permalink
setup gating for <TextOptimized /> (#45031)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #45031

changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D58672844

fbshipit-source-id: 2c99d3b66665c8dc0b796713b21d91211b469d81
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Jun 18, 2024
1 parent d8739e1 commit 2f0c06d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/react-native/Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import type {PressEvent} from '../Types/CoreEventTypes';
import type {TextProps} from './TextProps';

import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
import * as PressabilityDebug from '../Pressability/PressabilityDebug';
import usePressability from '../Pressability/usePressability';
import flattenStyle from '../StyleSheet/flattenStyle';
Expand Down Expand Up @@ -337,4 +338,8 @@ const verticalAlignToTextAlignVerticalMap = {
middle: 'center',
};

module.exports = Text;
module.exports = (
ReactNativeFeatureFlags.shouldUseOptimizedText()
? require('./TextOptimized')
: Text
) as typeof Text;
Original file line number Diff line number Diff line change
Expand Up @@ -8048,7 +8048,7 @@ exports[`public API should not change unintentionally Libraries/Text/Text.js 1`]
TextProps,
React.ElementRef<typeof NativeText | typeof NativeVirtualText>,
>;
declare module.exports: Text;
declare module.exports: typeof Text;
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ const definitions: FeatureFlagDefinitions = {
description:
'Enables use of AnimatedObject for animating transform values.',
},
shouldUseOptimizedText: {
defaultValue: false,
description: 'Use optimized version of <Text /> component.',
},
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: {
defaultValue: false,
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<edd8917cdda9c37bbe84d036f62a36ba>>
* @generated SignedSource<<522f11a571457cb932f451cf81bd384a>>
* @flow strict-local
*/

Expand Down Expand Up @@ -32,6 +32,7 @@ export type ReactNativeFeatureFlagsJsOnly = {
enableAccessToHostTreeInFabric: Getter<boolean>,
isLayoutAnimationEnabled: Getter<boolean>,
shouldUseAnimatedObjectForTransform: Getter<boolean>,
shouldUseOptimizedText: Getter<boolean>,
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter<boolean>,
shouldUseSetNativePropsInFabric: Getter<boolean>,
};
Expand Down Expand Up @@ -97,6 +98,11 @@ export const isLayoutAnimationEnabled: Getter<boolean> = createJavaScriptFlagGet
*/
export const shouldUseAnimatedObjectForTransform: Getter<boolean> = createJavaScriptFlagGetter('shouldUseAnimatedObjectForTransform', false);

/**
* Use optimized version of <Text /> component.
*/
export const shouldUseOptimizedText: Getter<boolean> = createJavaScriptFlagGetter('shouldUseOptimizedText', false);

/**
* removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android
*/
Expand Down

0 comments on commit 2f0c06d

Please sign in to comment.