Closed
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>