diff --git a/src/public/js/components/movies/list.js b/src/public/js/components/movies/list.js index c27b600..889b760 100644 --- a/src/public/js/components/movies/list.js +++ b/src/public/js/components/movies/list.js @@ -32,17 +32,32 @@ function MoviePosters(props) { ); } -function MoviePoster(props) { - const imgUrl = '/img/movies/' + props.data.imdb_id +'.jpg'; - const selected = props.selected ? ' thumbnail-selected' : ''; - const imgClass = 'thumbnail' + selected; - return ( -
- - - -
- ); +class MoviePoster extends React.Component { + constructor(props) { + super(props); + this.state = { + src: `/img/movies/${this.props.data.imdb_id}.jpg`, + } + this.handleError = this.handleError.bind(this); + } + handleError() { + this.setState({ src: '/img/noimage.png' }); + } + render() { + const selected = this.props.selected ? ' thumbnail-selected' : ''; + const imgClass = 'thumbnail' + selected; + return ( +
+ + + +
+ ); + } } function MovieDetails(props) {