Skip to content

Instantly share code, notes, and snippets.

@showmeyourhits
Last active December 5, 2017 20:46
Show Gist options
  • Save showmeyourhits/6a99e02b23aba8b138736ccbb19d77ae to your computer and use it in GitHub Desktop.
Save showmeyourhits/6a99e02b23aba8b138736ccbb19d77ae to your computer and use it in GitHub Desktop.
/* 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