From 1937b7ffb171f5df70db0485c889dc6103c6cd26 Mon Sep 17 00:00:00 2001 From: John Mantas Date: Sat, 11 Aug 2018 01:20:44 +0300 Subject: [PATCH] fix: Add fallback if book properties not available --- src/Book.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Book.js b/src/Book.js index 3aa094b..a5b25ab 100644 --- a/src/Book.js +++ b/src/Book.js @@ -2,10 +2,15 @@ import React from 'react' class Book extends React.Component { render() { + let image, title, authors + this.props.book.imageLinks ? image = this.props.book.imageLinks.smallThumbnail : image = '' + this.props.book.title ? title = this.props.book.title : title = 'No title available' + this.props.book.authors ? authors = this.props.book.authors : authors = 'No authors available' + return (
-
+
-
{this.props.book.title}
-
{this.props.book.authors}
+
{title}
+
{authors}
); }