Last active
February 11, 2018 22:32
-
-
Save BrodaNoel/73036741452423405b589f70ed4f2bad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option 1 | |
render() { | |
return ( | |
<div className="App"> | |
<h1>The title</h1> | |
{ | |
this.state.movies.length > 0 && ( | |
<h1>Movie list</h1> | |
<MovieList data={this.state.movies} /> | |
) | |
} | |
{ | |
this.state.comics.length > 0 && ( | |
<h1>Comic list</h1> | |
<ComicList data={this.state.comics} /> | |
) | |
} | |
</div> | |
); | |
} | |
// Option 2 | |
render() { | |
if (something) { | |
return ( | |
Something here... | |
); | |
} | |
if (!something) { | |
return ( | |
Something here... | |
); | |
} | |
} | |
// Option 3 | |
render() { | |
let theElement = null; | |
if (something) { | |
theElement = <Xxx />; | |
} else { | |
theElement = <Yyy />; | |
} | |
return ( | |
<div> | |
<Greeting isLoggedIn={isLoggedIn} /> | |
{theElement} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment