created DisplayMovieRow component
This commit is contained in:
42
src/containers/DisplayMovieRow.js
Normal file
42
src/containers/DisplayMovieRow.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import React from 'react';
|
||||
// import MovieGenre from './components/MovieGenre';
|
||||
import MovieGenre from '../components/MovieGenre';
|
||||
|
||||
const getMovieRows = (movies, url) => {
|
||||
console.log('getMovieRow() ', movies, url);
|
||||
const movieRow = movies.map((movie) => {
|
||||
let movieImageUrl =
|
||||
'https://image.tmdb.org/t/p/w500/' + movie.backdrop_path;
|
||||
if (
|
||||
url === `/discover/tv?api_key=${process.env.API_KEY}&with_networks=213`
|
||||
) {
|
||||
movieImageUrl =
|
||||
'https://image.tmdb.org/t/p/original/' + movie.poster_path;
|
||||
}
|
||||
|
||||
if (movie.poster_path && movie.backdrop_path !== null) {
|
||||
const movieComponent = (
|
||||
<MovieGenre
|
||||
key={movie.id}
|
||||
url={url}
|
||||
posterUrl={movieImageUrl}
|
||||
movie={movie}
|
||||
/>
|
||||
);
|
||||
|
||||
return movieComponent;
|
||||
}
|
||||
});
|
||||
return movieRow;
|
||||
};
|
||||
|
||||
export default function DisplayMovieRow(props) {
|
||||
console.log('DisplayMovieRow.render()', props.movies);
|
||||
let movies = getMovieRows(props.movies, props.url);
|
||||
return (
|
||||
<>
|
||||
<h1 className="movieShowcase__heading">{props.title}</h1>
|
||||
<div className="movieShowcase__container">{movies}</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user