title: How to display an svg image to img tag's onerror property with Typescript?
body: <p>I have an image that display a jpg, but when there is an error, it shall display an svg image. However, Typescript claims onerror property only accept string. Is there a way to display an svg or a component instead with the onerror img property?</p>
  
  <p>Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> &lt;img
        width="100px"
        height="100px"
        src="myimg.jpg"
        onError={(e) =&gt; {(e.target as HTMLImageElement).src ="error.jpg"}}
      /&gt;
  
  // And with the svg:
  
   &lt;img
        width="100px"
        height="100px"
        src="myimg.jpg"
        onError={(e) =&gt; {(e.target as HTMLImageElement).src =&lt;Icon src="error"/&gt;}}
      /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am using React + Typescript. </p>