title: JavaScript Check if File exists, if not then
body: <p>I am working on a table where I need to return images in the first column.
  The below code works fine except if it doesn't find the image then I get an error.</p>
  
  <p>I would like to check if the file exists and if it does not exist, to return a default image. How should I approach this?</p>
  
  <p>Thanks,</p>
  
  <pre><code>              Cell: cellProps =&gt; {
                  const imgPath = cellProps.row.ExternalID;
                  return (
                    &lt;img
                      src={require(`../images/${imgPath}.png`)}
                      alt=""
                    /&gt;
                  );
                }
  </code></pre>