You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
render () {
let title = ""
return (
<View>
{ title &&
<Text>{title}</Text>
}
</View>
)
}
It will throw that error, because IMHO it parses text in quotes like boolean true and goes to the next chunk (View and Text) and renders it successfully, but if there if empty quotes it tries to set raw text in view element. Here if snack example https://snack.expo.io/BJnJJBg5Z
this is expected behavior and the error you get is self explanatory. idk if there is anything to improve here. ("" && true) will return empty string in javascript which is why you see the error. you can do something like: { title ? <Text>{title}</Text> : null }
Is this a bug report?
yes
If you'll try to execute something like this
It will throw that error, because IMHO it parses text in quotes like boolean true and goes to the next chunk (View and Text) and renders it successfully, but if there if empty quotes it tries to set raw text in view element. Here if snack example https://snack.expo.io/BJnJJBg5Z
Have you read the Contributing Guidelines?
Yes
Environment
react-native -v
:react-native-cli: 2.0.1
react-native: 0.45.1
node -v
:v7.10.1
npm -v
:4.2.0
yarn --version
:0.27.5
Then, specify:
Steps to Reproduce
https://snack.expo.io/BJnJJBg5Z
(Write your steps here:)
render
:<View>{ text && <Text>{text}</Text> }</View>
, where text is empty string""
Expected Behavior
wont render and no error occurs
(Write what you thought would happen.)
Actual Behavior
Error that is hard to discover
(Write what happened. Add screenshots!)
Reproducible Demo
https://snack.expo.io/BJnJJBg5Z
(Paste the link to an example project and exact instructions to reproduce the issue.)
I don't think it needs more explains :)
The text was updated successfully, but these errors were encountered: