-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
feat: add more context to invalid text string parents #32544
feat: add more context to invalid text string parents #32544
Conversation
Base commit: 88ebec9 |
Base commit: 88ebec9 |
I believe that these changes must be applied in the react repo ReactNativeHostConfig & ReactFabricHostConfig |
What @ecreeth said, but also… check out these two PRs by me:
tl;dr — I previously attempted a similar change, but was recommended to revert it because @acdlite and @sebmarkbage raised concerns with logging arbitrary strings which may be sensitive (e.g. passwords, banking information). |
Perhaps a fair compromise is to log this information in debug builds only? |
@Yonom — Some people unknowingly run debug builds in production (e.g. when you see RedBox displaying in some production apps), so there is still some risk there. @EvanBacon — What do you think about only appending the string if an opt-in flag is set (e.g. |
I am going to close this PR because the change has to be made in the React repository, as @ecreeth suggested above. |
Opened a PR for adding to react proper.
I don't quite understand this issue since the error would be thrown when attempting to explicitly render a value to the screen, e.g. someone wrapped their password in JSX and passed it to the render method lol. |
Yeah, that is the concern. Either by design or by mistake, someone could conceivably render sensitive information (e.g. password, social security number, credit card information) as text without |
For posterity, facebook/react#22725 seems to be the React PR. Let's move future discussion about this contribution to that repository. |
Summary
The stack traces shown in LogBox often just point to fast refresh and don't provide much context into cases where a user adds a string outside of a Text element, this PR improves discoverability a little by adding the invalid text to the error message.
Changelog
[General] [Added] - Improved invalid text parent error message.
Test Plan
Tried it in a basic case:
<View>foobar</View>
will throw:Error: Text strings "foobar" must be rendered within a <Text> component.