Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to use if else inside jsx in react

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

render() {
    return (   
        <View style={styles.container}>
            { this.renderElement() }
        </View>
    )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jsx #react
ADD COMMENT
Topic
Name
7+5 =