how to use if condition in react native text code example
Example 1: if statement in react native
renderConditionalText() {
if (this.state.isSignUp) {
return <Text> Sign Up </Text>;
}
return <Text> Forgot Password </Text>;
}
Example 2: return using if condition react native
constructor() {
super();
this.state ={
status:true
}
}
render() {
return(
{ this.state.status === true ?
<TouchableHighlight onPress={()=>this.hideView()}>
<View style={styles.optionView}>
<Text>Ok Fine :)</Text>
</View>
</TouchableHighlight>
:
<Text>Ok Fine.</Text>
}
);
}
hideView(){
this.setState({
home:!this.state.status
});
}