react native conditional rendering
render(){
return(
<View>
{this.state.error && <Text style={{ color: 'red' }}>{this.state.errorMessage}</Text>}
<Text>Hello World!</Text>
</View>
);
}
There you go.
This below code also check empty string.
render(){
return(
<View>
{!!this.state.error && <Text>{this.state.errorMessage}</Text>}
</View>
);
}