RN(View): Remove TextAncestor provider#29736
Closed
ecreeth wants to merge 1 commit into
Closed
Conversation
Base commit: b0fbbe5 |
Base commit: b0fbbe5 |
Member
|
Resetting the text ancestor is required to change what kinds of Text components render (inline text nodes, or block level text nodes). We need to reset that in View as text elements inside of a View need to reset to be a block level text, not an inline text node. |
facebook-github-bot
pushed a commit
that referenced
this pull request
Mar 21, 2023
Summary: Text need to know if is a descendant of a text in order to proper render nested text. For this react-native uses the textAncestor provider #29736 (comment). This provides a not so ideal DX when profiling/Debugging as the view is polluted with TextAncestor.provider on each view render (As is the main render piece this happens quite often). The idea behind of this PR is to just reset the context when view is a descendant of a text (Not so common case) rather than resetting all the time. | Before | After | | ------------- | ------------- | |  |  | From my understanding of how hooks works this shouldn't degrade the performance and didn't spot any diff profiling my app (For better or worse). ## Changelog [INTERNAL] [CHANGED] - Only reset textAncesor when is a child of text Pull Request resolved: #36520 Test Plan: https://github.com/facebook/react-native/blob/main/packages/rn-tester/js/examples/Text/TextExample.ios.js Reviewed By: necolas Differential Revision: D44213843 Pulled By: javache fbshipit-source-id: 246ac22557dc7794741fd9732d399fe8b9256f11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I think the
TextAncestorprovider is unnecessary in theViewcomponent as the rendererwill throw an error if it doesn't find the value in the context anyway.
Changelog
[JavaScript] [Changed] - Remove TextAncestor provider for
ViewTest Plan
yarn test passed
RNTester
Androidapp build successfulA
Viewcomponent with text must throw error:Text strings must be rendered within a <Text> component.Below we can see that all the providers of the
Viewcomponent have been eliminated from the component hierarchy