Answers for "if else condition inside react native return"

0

if else condition inside react native return

If you want to render the element conditionally then use ternary operator, like
this:

render() {
    return (   
        <View style={styles.container}>
            {this.state.value == 'news'? <Text>data</Text>: null }
        </View>
    )
}

Another option is, call a function from jsx and put all the if-else logic inside
that, like this:

renderElement(){
   if(this.state.value == 'news')
      return <Text>data</Text>;
   return null;
}

render() {
    return (   
        <View style={styles.container}>
            { this.renderElement() }
        </View>
    )
}

If you want to render the element conditionally then use ternary operator, like 
this:

render() {
    return (   
        <View style={styles.container}>
            {this.state.value == 'news'? <Text>data</Text>: null }
        </View>
    )
}
Another option is, call a function from jsx and put all the if-else logic 
inside that, like this:

renderElement(){
   if(this.state.value == 'news')
      return <Text>data</Text>;
   return null;
}

render() {
    return (   
        <View style={styles.container}>
            { this.renderElement() }
        </View>
    )
}
Posted by: Guest on September-27-2021
0

if statement in react native

renderConditionalText() {
    if (this.state.isSignUp) {
        return <Text> Sign Up </Text>;
    }
     return <Text> Forgot Password </Text>; 
}
Posted by: Guest on April-08-2021
0

if else condition inside react native return

If you want to render the element conditionally then use ternary operator, like
this:

render() {
    return (   
        <View style={styles.container}>
            {this.state.value == 'news'? <Text>data</Text>: null }
        </View>
    )
}

Another option is, call a function from jsx and put all the if-else logic inside
that, like this:

renderElement(){
   if(this.state.value == 'news')
      return <Text>data</Text>;
   return null;
}

render() {
    return (   
        <View style={styles.container}>
            { this.renderElement() }
        </View>
    )
}

If you want to render the element conditionally then use ternary operator, like 
this:

render() {
    return (   
        <View style={styles.container}>
            {this.state.value == 'news'? <Text>data</Text>: null }
        </View>
    )
}
Another option is, call a function from jsx and put all the if-else logic 
inside that, like this:

renderElement(){
   if(this.state.value == 'news')
      return <Text>data</Text>;
   return null;
}

render() {
    return (   
        <View style={styles.container}>
            { this.renderElement() }
        </View>
    )
}
Posted by: Guest on September-27-2021
0

if statement in react native

renderConditionalText() {
    if (this.state.isSignUp) {
        return <Text> Sign Up </Text>;
    }
     return <Text> Forgot Password </Text>; 
}
Posted by: Guest on April-08-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language