I am getting (sometimes) an attribute in a JSON response called smallThumbnail
. It may or may not exist... along with parent and grandparent properties imageLinks
and volumeInfo
. Is there a cleaner way than this to prevent me from using a smallThumbnail
value that doesn't exist and throwing errors?
<img src={option.volumeInfo &&
option.volumeInfo.imageLinks &&
option.volumeInfo.imageLinks.smallThumbnail ?
option.volumeInfo.imageLinks.smallThumbnail :
"https://up.quizlet.com/1hbijs-gYV7D-256s.jpg"}
width="40" height="40" />