Created
November 11, 2016 18:09
-
-
Save mauricedb/795c297e22f93bde0f5953ab13c11b13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { PropTypes } from 'react'; | |
import GenreRow from './genre-row'; | |
const GenreList = ({ movies, startPlaying }) => { | |
const allGenres = {}; | |
movies.forEach((movie) => { | |
movie.genre.forEach((genre) => { | |
if (allGenres[genre]) { | |
allGenres[genre].push(movie); | |
} else { | |
allGenres[genre] = [movie]; | |
} | |
}); | |
}); | |
const genres = Object.keys(allGenres).sort(); | |
return ( | |
<div> | |
{genres.map(genre => <GenreRow | |
key={genre} | |
genre={genre} | |
movies={allGenres[genre]} | |
startPlaying={startPlaying} | |
/>)} | |
</div> | |
); | |
}; | |
GenreList.propTypes = { | |
movies: PropTypes.array.isRequired, | |
startPlaying: PropTypes.func.isRequired, | |
}; | |
export default GenreList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment