JSFiddle - React, Tailwind, and code Playground
HTML
note that the <b>image.gif</b> is not exist and the alternative is loaded
<br><br>
<img id="one" src="image.gif" onerror="imgError(this)">
<br><br>
<img src="notexistether.jpg" onerror="imgError(this)">
JavaScript
function imgError(me)
{
var AlterNativeImg =
"http://www.gravatar.com/avatar/98f3776a8cec43ac3e0a363fce92cb29?s=128&d=identicon&r=PG"
// to avoid the case that even the alternative fails
if(AlterNativeImg != me.src)
me.src = AlterNativeImg;
}