Skip to content

Instantly share code, notes, and snippets.

@BrodaNoel
Last active February 11, 2018 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrodaNoel/73036741452423405b589f70ed4f2bad to your computer and use it in GitHub Desktop.
Save BrodaNoel/73036741452423405b589f70ed4f2bad to your computer and use it in GitHub Desktop.
// 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