Use public unstable_TextAncestorContext API#477
Conversation
|
Cross-repo follow-up: facebook/react-native#56813 (draft) deletes the now-unneeded compatibility shim on the React Native side. It's gated on this PR landing and a strict-dom release shipping with the new import path. |
|
Thank you! I think the branch associated with this pull request has several other commits/features though. If you're able to separate the Use public unstable_TextAncestorContext API commit from the other changes I will merge |
React Native 0.81 exposed TextAncestorContext as a public API (facebook/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.
1f844c0 to
39f7828
Compare
|
Done! only the Use public unstable_TextAncestorContext API commit remains. Quick heads-up before you merge: unstable_TextAncestorContext needs RN ≥ 0.81, but main's peer dep is still >=0.79.5. So on its own this could break for users on 0.79.x or 0.80.x. Easiest fix is probably merging #475 first since it bumps the peer dep anyway. But if you'd rather take this one first, I can tack on a >=0.81.0 bump here. Let me know what you prefer. |
React Native 0.81 promoted
TextAncestorContextto a public API in facebook/react-native#52368, so we no longer need to reach intoreact-native/Libraries/Text/TextAncestor.The deep-import file on the RN side only exists as a shim for this repo:
So merging this clears the cross-repo reference the TODO is waiting on, and the shim can be deleted on the RN side afterwards (I'll open that PR once this lands).
It's the same Context object under the hood — no behavior change, snapshots are unchanged.
Changes
src/native/react-native/TextAncestorContext.js: importunstable_TextAncestorContextfromreact-nativeinstead of the deep path.tests/__mocks__/react-native/index.js: exportunstable_TextAncestorContextso the mock matches.tests/__mocks__/react-native/Libraries/Text/TextAncestor.js: deleted, no longer referenced.Depends on
#475 —
unstable_TextAncestorContextneeds React Native ≥ 0.81, which the peer-dep bump there handles.