-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
Improving feedback for "Text strings must be rendered within a <Text> component." errors. #20803
Conversation
Hi @dmlux! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
I wonder is there way to display additional information in the error box like a hint for the developer how to fix the error? |
Comparing: 483358c...5483801 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
I previously attempted this in #19581, but I reverted it in #19723 because of feedback that I received (from @sebmarkbage, IIRC) around security implications of logging arbitrarily user-generated content. |
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. |
Commenting to keep this PR open. Would be nice to improve the developer experience with that PR |
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. |
There is another open PR that I just commented on last week to do this. |
See #22725. |
Summary
This PR is meant to be a draft for changes in the renderer. In our company we sometimes facing "Text strings must be rendered within a <Text> component." errors related to conditional concatenation with components. Since conditionals are often values provided by services, it is difficult to track down the exact location where they occur. Unfortunately, both the error component stack and the call stack do not provide enough information to find the corresponding location in the code. For this reason, we patched React Native locally to drastically reduce the debugging time associated with such errors.
The provided changes of this PR are basically the patch applied locally to React Native in our project. The improvements to the messages from our patch include the actual text that could not be rendered, as well as a sibling component and its exact location in the source code. This allows my colleagues and me to quickly track down problems and locate the approximate point of failure in our code. It also gives a hint that the problem might be related to a concatenation between a value and a component.
However, this solution is not quite perfect, as the information is not detailed enough in cases where the error is caused by code, such as the following:
Obviously, in this situation, there are no sibling components from which we can infer the source code location or parent component. Nevertheless, in such cases the message contains at least the text which could not be rendered without
<Text>
component. The question we have is whether it is possible to make the error message more verbose in all cases?