Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow third-party react-native libraries to render text #27833

Conversation

fabOnReact
Copy link

@fabOnReact fabOnReact commented Dec 13, 2023

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:

  • The components are based on the react-native implementation (for ex. ReactTextView, ReactTextViewManager, and ReactTextShadowNode).
  • It is possible to add javascript, android and iOS patches
  • No issues upgrading react-native
  • The fixes can be used selectively in the application (for ex. by using import { TextImproved } from 'react-native-improved')
  • Allows a wider community to contribute to react-native
  • May help make the release process of react-native easier in the future
  • Fast development workflow (building react-native from source with third party libraries may take 10-30 minutes)

How did you test this change?

  • I tested the solution with patch-package in the react-native-improved example
  • I tested the solution in a brand new react-native 0.73 app after installing react-native-improved npm package
Before After

@react-sizebot
Copy link

Comparing: 493610f...5600bae

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 175.90 kB 175.90 kB = 54.76 kB 54.75 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.97 kB 177.97 kB = 55.39 kB 55.39 kB
facebook-www/ReactDOM-prod.classic.js = 570.21 kB 570.21 kB = 100.35 kB 100.35 kB
facebook-www/ReactDOM-prod.modern.js = 554.06 kB 554.06 kB = 97.43 kB 97.43 kB
test_utils/ReactAllWarnings.js Deleted 67.41 kB 0.00 kB Deleted 16.49 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 67.41 kB 0.00 kB Deleted 16.49 kB 0.00 kB

Generated by 🚫 dangerJS against 5600bae

@fabOnReact fabOnReact marked this pull request as ready for review December 14, 2023 05:28
Copy link

github-actions bot commented Apr 5, 2024

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 5, 2024
Copy link

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@github-actions github-actions bot closed this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to use a custom-made native component to render text strings
3 participants