title: (Reactjs) How to submit the file immediately after selected the file
body: <p>I am trying to submit an image using input field without a submit button. When the file is selected, it will be submitted automatically. I am thinking doing it like this:</p>
  <pre><code>const [image, setImage] = useState(null);
  
  const updateState = (e) =&gt; {
    setImage(e.target.files[0]);
  }
  
  const submitFile = async () =&gt; {
    ...submit the file...
  }
   
  &lt;input accept='image/*' type='file' onChange={() =&gt; { updateState(); submitFile(); }} /&gt;
  </code></pre>
  <p>I really want to know is there a better way to do this? Because I not feeling right about this, it seems not very programmatic.</p>