Skip to content

Commit

Permalink
fix crash when loading books without a thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
vivshaw committed Aug 28, 2017
1 parent a8a9414 commit 25ba594
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/components/Book.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { getRating, setRating } from '../utils/RatingsAPI';
import type { BookType } from '../common/flowTypes';
import { shelfData } from '../common/commonData';

// Images
import defaultThumb from '../default-thumbnail.png';

/* ------------------------------------------------------------------
----------------------------- STYLES -----------------------------
------------------------------------------------------------------ */
Expand Down Expand Up @@ -99,18 +102,15 @@ class Book extends Component {
}

render() {
const {
book: {
id,
title,
subtitle,
description,
authors,
imageLinks: { thumbnail }
}
} = this.props;
const { book: { id, title, subtitle, description, authors } } = this.props;
const { rating, shelf } = this.state;

// if the book lacks imageLinks.thumbnail, use a default thumbnail
const thumbnail =
this.props.book.imageLinks && this.props.book.imageLinks.thumbnail
? this.props.book.imageLinks.thumbnail
: defaultThumb;

// Map shelfData into MenuItems for our shelf dropdown
const shelfDropdownItems = shelfData.maybeShelves.map(shelf => {
return (
Expand Down
Binary file added src/default-thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 25ba594

Please sign in to comment.