Mar.10

Add value to existing array group : React Learning

const genre_with_all = [{‘name’:”All Movies”},…getGenres()];
this.setState({
movies:getMovies(),
//genre:getGenres(),
genre:genre_with_all,
})
+++++++++++++++++++++++++++
+++++++++++++++++++++++++++
export const genres = [
{ _id: “5b21ca3eeb7f6fbccd471818”, name: “Action” },
{ _id: “5b21ca3eeb7f6fbccd471814”, name: “Comedy” },
{ _id: “5b21ca3eeb7f6fbccd471820”, name: “Thriller” }
];
export function getGenres() {
return genres.filter(g=>g);
}
Share this Story:
  • facebook
  • twitter
  • gplus

Leave a comment

Facebook Comment