Created
February 11, 2018 22:33
-
-
Save BrodaNoel/766fb72f4a5cc6935cf931864e0e7870 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
// src/components/Conditional.jsx | |
const Conditional = (props) => { | |
return( | |
!!props.if && props.children | |
); | |
} | |
export default Conditional; | |
// Implementation: | |
import Conditional from 'components/Conditional'; | |
render() { | |
return ( | |
<div className="App"> | |
<h1>The title</h1> | |
<Conditional if={this.state.movies.length > 0}> | |
<h1>Movie list</h1> | |
<MovieList data={this.state.movies} /> | |
</Conditional> | |
<Conditional if={this.state.comics.length > 0}> | |
<h1>Comic list</h1> | |
<ComicList data={this.state.comics} /> | |
</Conditional> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment