I'm handling data I read from Newsapi.org. The problem is that sometimes I get the news title but the image url returns null.
I did this to do conditional rendering so it shows another image when the return variable is null. It is not showing the replace image when the response is null.
<div class="col-2">
{ article.urlToImage != 'null' ?
<a href={article.url} class="thumbnail">
<img src={article.urlToImage} class="img-fluid" />
</a>
:
<a href={article.url} class="thumbnail">
<img src="http://www.publicengagement.ac.uk/sites/default/files/styles/content_width/public/hero/large-crowd-of-people-small.jpg" class="img-fluid" />
</a>
}
</div>