Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6212

How to put View into ternary conditional? [closed]

$
0
0

first glance, I have following snippet:

{ (condition) ?<View/> 1 </View> : <View><Text>2</Text></View>}

=> it'works

However, If I replace View 2 by View 3 with content ...

<View> 3...   {this.props.items.map((item, index) => {        { (condition) ?          stuff 1 : stuff 2       }   }...</View>

=> it show error: djacent jsx elements must be wrapped in an enclosing tag

Any idea to resolve it, thanks your interest!

ps: if I put View 3 outside of ternary conditional, it operate normally


Viewing all articles
Browse latest Browse all 6212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>