I am evaluating some variables and using the result to conditionally render elements.
This is the evaluation
const condition = this.props.badgeCount > 0
and using the result like this
<View>
{condition && (
<View>
<Text>
{this.props.badgeCount}
</Text>
</View>
)}
</View>
And RN fails with the error
text strings must be rendered within a text component
and works well when I change condition
to
const condition = Boolean(this.props.badgeCount > 0)
So, clearly the results returned back are something like "true"
or "false"
.
My question is why is this, because that is clearly an evaluation that should return a boolean and also is there a way other than the one I am using, to solve this problem?