Allow third-party react-native libraries to render text #27833
Closed
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
It is not possible to publish a third-party library Text/TextInput component that accepts raw text as children.
The function createTextInstance triggers an error if the name of the HostComponent is not one of those defined in getChildHostComponent.
This PR adds one additional type to the react-native renderer to be used by third-party libraries (fixes facebook/react-native#25136).
Additional info on the motivations for this change
The react-native team previously suggested publishing react-native patches for Text and TextInput through a third-party library (react-native-community/discussions-and-proposals#731 (reply in thread)).
The library react-native-improved provides react-native bug fixes without using patch-package or forking react-native.
The project is currently a proof of concept and applies only one fix (PR facebook/react-native#41770) to the react-native Text component, but more components and fixes could be published in the future.
The advantages of this approach over forking react-native are the following:
import { TextImproved } from 'react-native-improved'
)How did you test this change?