I've been trying to search this on stackoverflow but the answers arent exactly what im looking for, plus they use jquery. So is there any way of determing if a div element contains only an image element inside it, and therefore returning a boolean? I have tried things like:
<div className={this.find('img').length}?'hasImg':'noImg'>
<img src=''>
</div>
but this returned false. Even if this would work, I'd like it to return true only if there is an image regardless if there is a p tag or something else inside.