Respond to natural conditional visualization

I am trying to use the inline if statement to check if a piece of data exists and if it displays it. this code is currently in my render, return block.

the problem i am facing is that using this the content is no longer displayed

{(() => { if (this.props.data.size) { <Text style={styles.headerLabel}>Sizes</Text> {(this.props.data.size||[]).map((section,i) => ( <AddToCartRow key={i} data={section} productName={this.props.data.name} value={Config.priceToPriceWithCurrency(section.price)} /> ))} } })()} 
+5
source share
1 answer

 render(){ return( <View> {this.state.error && <Text style={{ color: 'red' }}>{this.state.errorMessage}</Text>} <Text>Hello World!</Text> </View> ); } 

There you go.

+21
source

Source: https://habr.com/ru/post/1263912/


All Articles