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}
1var loginButton;
2if (loggedIn) {
3 loginButton = <LogoutButton />;
4} else {
5 loginButton = <LoginButton />;
6}
7
8return (
9 <nav>
10 <Home />
11 {loginButton}
12 </nav>
13);
14
1function Mailbox(props) {
2 const unreadMessages = props.unreadMessages;
3 return (
4 <div>
5 <h1>Hello!</h1>
6 {unreadMessages.length > 0 &&
7 <h2>
8 You have {unreadMessages.length} unread messages.
9 </h2>
10 }
11 </div>
12 );
13}
1if (coinToss() === 'heads') {
2 img = <img src={pics.kitty} />
3} else {
4 img = <img src={pics.doggy} />
5}