react native use if else in jsx code example
Example 1: if else react render in jsc
const functionalComponent=()=> {
return (
<div>{
props.isFeatured ? (
<div className="featured_ovelay_icon">lol</div>
) : ("")
}
</div>
);
}
Example 2: 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>
)
}