Skip to content

Commit c4e69e0

Browse files
yaminyassinYamin Yassin
andauthored
Use public unstable_TextAncestorContext API (#477)
* Use public unstable_TextAncestorContext API React Native 0.81 exposed TextAncestorContext as a public API (react/react-native#52368). Switch from the deep import path 'react-native/Libraries/Text/TextAncestor' to the public 'unstable_TextAncestorContext' export. The deep-import target file in React Native exists solely as a backwards-compatibility shim for react-strict-dom — see https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Text/TextAncestor.js which carries a TODO from @huntie to delete it once this cross-repo reference is fixed. Same React Context object, no behavioral change. Test mock updated to match the new import path; old deep-import mock deleted. * Update benchmark react-native mock for unstable_TextAncestorContext --------- Co-authored-by: Yamin Yassin <Yamin.Yassin+CAG@cagtechhub.com>
1 parent 78ba6bd commit c4e69e0

6 files changed

Lines changed: 5 additions & 28 deletions

File tree

packages/benchmarks/perf/mocks/TextAncestorContext.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/benchmarks/perf/mocks/react-native.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ export const TextInput = 'TextInput';
111111

112112
export const Text = 'Text';
113113

114+
export const unstable_TextAncestorContext = 'TextAncestorContext';
115+
114116
export const View = 'View';
115117

116118
export const experimental_LayoutConformance = 'LayoutConformance';

packages/benchmarks/perf/rollup.config.mjs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ const config = [
4343
__dirname,
4444
'./mocks/ViewNativeComponent.js'
4545
)
46-
},
47-
{
48-
find: 'react-native/Libraries/Text/TextAncestor',
49-
replacement: path.resolve(
50-
__dirname,
51-
'./mocks/TextAncestorContext.js'
52-
)
5346
}
5447
]
5548
}),

packages/react-strict-dom/src/native/react-native/TextAncestorContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
* @flow strict-local
88
*/
99

10-
import TextAncestorContext from 'react-native/Libraries/Text/TextAncestor';
10+
import { unstable_TextAncestorContext as TextAncestorContext } from 'react-native';
1111
export { TextAncestorContext };

packages/react-strict-dom/tests/__mocks__/react-native/Libraries/Text/TextAncestor.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/react-strict-dom/tests/__mocks__/react-native/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export const View = 'View';
120120

121121
export const experimental_LayoutConformance = 'LayoutConformance';
122122

123+
export const unstable_TextAncestorContext = 'TextAncestorContext';
124+
123125
export const useColorScheme = jest.fn().mockReturnValue('light');
124126

125127
export const useWindowDimensions = jest

0 commit comments

Comments
 (0)