-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Closed
Labels
BugDXIssues concerning how the developer experience can be improved.Issues concerning how the developer experience can be improved.Platform: AndroidAndroid applications.Android applications.Platform: iOSiOS applications.iOS applications.StaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.📮Known IssuesThis indicates an issue that refers to a bug or limitation of RN that is not currently being handledThis indicates an issue that refers to a bug or limitation of RN that is not currently being handled
Description
@hramos here. This issue has been modified from its original content, in order to convey the latest status of this issue. You may refer to the edit history to see what @mattermoran originally reported.
Environment:
[skip envinfo]
This issue only affected Android in older releases, but is now consistent across both iOS and Android platforms as of 0.57.8.
Description
Using JSX that conditionally renders a Text element can lead to a RedBox error, "Invariant Violation: Text strings must be rendered within a Text component", if the condition is "falsy", as in the following example:
<View>
{someTextValue && <Text>{someTextValue}</Text>}
</View>
This can lead to a confusing development experience, as the pattern is documented in React's JSX docs.
Workaround
Use a ternary operator.
<View>
{someTextValue ? <Text>{someTextValue}</Text> : null}
</View>
jamonholmgren, ATShiTou, matthewlamhk01, irekrog, jingzho and 2 more
Metadata
Metadata
Assignees
Labels
BugDXIssues concerning how the developer experience can be improved.Issues concerning how the developer experience can be improved.Platform: AndroidAndroid applications.Android applications.Platform: iOSiOS applications.iOS applications.StaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.📮Known IssuesThis indicates an issue that refers to a bug or limitation of RN that is not currently being handledThis indicates an issue that refers to a bug or limitation of RN that is not currently being handled