JSFiddle - React, Tailwind, and code Playground

HTML

<svg height="300">
</svg>

JavaScript

var img = document.createElementNS("http://www.w3.org/2000/svg", "image");
img.addEventListener('load', function() { alert('loaded'); });
img.addEventListener('error', function() { alert('loading failed'); });
// or alternatively:
// img.onload = function() { alert('loaded'); }
img.width.baseVal.value = 200;
img.height.baseVal.value = 300;
img.href.baseVal = "http://via.placeholder.com/200x300";
document.getElementsByTagName("svg")[0].appendChild(img);