diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js index bc68479ae4b..807b1c73d16 100644 --- a/packages/react-native/Libraries/Text/Text.js +++ b/packages/react-native/Libraries/Text/Text.js @@ -19,6 +19,7 @@ import processColor from '../StyleSheet/processColor'; import Platform from '../Utilities/Platform'; import TextAncestor from './TextAncestor'; import {NativeText, NativeVirtualText} from './TextNativeComponent'; +import TextOptimized from './TextOptimized'; import * as React from 'react'; import {useContext, useMemo, useState} from 'react'; @@ -27,7 +28,7 @@ import {useContext, useMemo, useState} from 'react'; * * @see https://reactnative.dev/docs/text */ -const Text: React.AbstractComponent< +const TextLegacy: React.AbstractComponent< TextProps, React.ElementRef, > = React.forwardRef((props: TextProps, forwardedRef) => { @@ -308,7 +309,7 @@ const Text: React.AbstractComponent< ); }); -Text.displayName = 'Text'; +TextLegacy.displayName = 'TextLegacy'; /** * Returns false until the first time `newValue` is true, after which this will @@ -338,6 +339,17 @@ const verticalAlignToTextAlignVerticalMap = { middle: 'center', }; -module.exports = ((ReactNativeFeatureFlags.shouldUseOptimizedText() - ? require('./TextOptimized') - : Text): typeof Text); +const Text: React.AbstractComponent< + TextProps, + React.ElementRef, +> = React.forwardRef((props: TextProps, forwardedRef) => { + if (ReactNativeFeatureFlags.shouldUseOptimizedText()) { + return ; + } else { + return ; + } +}); + +Text.displayName = 'Text'; + +module.exports = Text; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index ccd24bce524..cd9e2b44087 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -8045,7 +8045,7 @@ exports[`public API should not change unintentionally Libraries/Text/Text.js 1`] TextProps, React.ElementRef, >; -declare module.exports: typeof Text; +declare module.exports: Text; " `;