title: Preview image upload with React Functions
body: <p>hello im trying to make a image upload and preview but i can only find react tutorials on how to do this using class components</p>
  
  <pre><code>import React from 'react';
  
  
  const AddNew = () =&gt; {
      const fileHandler = (event) =&gt; {
          console.log(event.target.files[0])
      }
      const alt = (event) =&gt; {
          return(event.target.files[0].name)
      }
      const preview = (event) =&gt; {
          return (
              URL.createObjectURL(event.target.files[0])
          )
      }
      return (
          &lt;div className="addNew"&gt;
              &lt;img src={preview} alt={alt}/&gt;
              &lt;input type="file" onChange={fileHandler} /&gt;
          &lt;/div&gt;
      )
  }
  
  export default AddNew
  </code></pre>
  
  <p>how do i preview it using this syntax?</p>
  
  <p>i get an error for invalid values for props 'src' and 'alt'</p>