1render () {
2 return (
3 <div>
4 {(() => {
5 if (someCase) {
6 return (
7 <div>someCase</div>
8 )
9 } else if (otherCase) {
10 return (
11 <div>otherCase</div>
12 )
13 } else {
14 return (
15 <div>catch all</div>
16 )
17 }
18 })()}
19 </div>
20 )
21}
22
1renderElement(){
2 if(this.state.value == 'news')
3 return <Text>data</Text>;
4 return null;
5}
6
7render() {
8 return (
9 <View style={styles.container}>
10 { this.renderElement() }
11 </View>
12 )
13}
1render() {
2 const isLoggedIn = this.state.isLoggedIn;
3 return (
4 <div>
5 The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in.
6 </div>
7 );
8}
1render() {
2 const isLoggedIn = this.state.isLoggedIn;
3 return (
4 <div>
5 The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in. </div>
6 );
7}
1if (isItemInCart) {
2 return prev.map(item =>
3 item.id === clickedItem.id
4 ? { ...item, amount: item.amount + 1 }
5 : item
6 );
7 }