title: React update state if image not found.
body: <p>I can't seem to wrap my head around this problem.  What I'm trying to do is have React attempt to verify an image is not returning a 404 to display an alternative image instead.  Something like the below does not work as React does not wait for the image to attempt to load for returning the component. </p>
  
  <pre><code>getInitialState: function () {
          var img = new Image();
          img.onerror = function() {
              img.src = "alternativeImage.jpg"
          },
          img.src = this.props.image;
          return {image: &lt;img src={img.src} /&gt;};
      },
  </code></pre>
  
  <p>The above code will display the images just fine but the 404 alternative image does not show up.  </p>
  
  <p>I've tried to place this in another method outside of getInitialState.  I've also tried to have it call an external method outside of the React component, but nothing works. </p>
  
  <p>There is a short hand method of adding onerror attribute on the image tag itself, but it seems React has the same issue of not executing that code and or updating itself based on the outcome.  </p>
  
  <p>I think the most frustrating part is that I cannot seem to have any function called that React would be able to work with from the JavaScript image object. </p>
  
  <p>Thanks for any help you can provide. </p>