Last active
December 5, 2017 20:46
-
-
Save showmeyourhits/6a99e02b23aba8b138736ccbb19d77ae 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
/* Pass list as props ... */ | |
class Song extends React.Component { | |
render = () => <span>{this.props.song.title}</span> | |
} | |
class Album extends React.Component { | |
render = () => ( | |
<section> | |
{this.props.songs.map(song => ( | |
<Song song={song} /> | |
))} | |
</section> | |
); | |
} | |
/* ... and render it like that */ | |
<Album songs={songs} /> | |
/* Pass list as children ... */ | |
class Album extends React.Component { | |
render = () => ( | |
<section> | |
{this.props.children} | |
</section> | |
); | |
} | |
/* ... and render it like that */ | |
<Album> | |
{songs.map(song => ( | |
<Song song={song} /> | |
))} | |
</Album> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment