-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Added more context to invalid text string errors #22725
Added more context to invalid text string errors #22725
Conversation
Comparing: 2db6d6a...871c7c7 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
Thanks again for your contribution, @EvanBacon. I'll copy over some of my feedback from facebook/react-native#32544:
It looks like the current status of this PR does not incorporate an opt-in flag as I previously suggested. Does this PR simply need to be updated, or do you have concerns about that approach? |
Is there some other kind of information we could add other than the text itself? Options don't seem ideal for this.
Is there a longer elaboration on why component stack does not provide enough information? Any concrete case I can look at? |
@gaearon perhaps the most minimal repro in native: Setup
Code
import { View } from "react-native";
export default function App() {
return (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}>
Hey
</View>
);
} Error Output
Initial LoadFast Refresh |
# Why - Temporary workaround for facebook/react#22725 - Unwrapped text strings are very difficult to find and cause critical errors to occur. When using expo/html-elements, devs have a much higher chance of accidentally making this mistake. - `@expo/html-elements` is web-first React Native and therefore should have first-class types and styles for `react-native-web`. This PR injects a native wrapper to strip out web styles that aren't supported. # How When a text child appears in View, the child is replaced by a red view with text indicating the string. A warning is also presented to attempt to provide a stack trace (which mostly doesn't help). # Test Plan - Added unit tests for the expected functionality. - I've been using this in my personal package `@bacons/react-views` for a while and it hurts to go back. <!-- Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction. --> # Checklist <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg: updated a module plugin). --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
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. |
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! |
Summary
This PR is a companion to facebook/react-native#32544 which was recommended here facebook/react-native#32544 (comment). In React Native, 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.
How did you test this change?
Update the error message format to include the invalid text string.