title: React - setState to True for All Empty Input Fields on Submit
body: <p>I'd like to dynamically setState to true, if an input field is empty. This is so I can style each input field when it is empty via css class when its' state is true. </p>
  
  <p>In my current code, it will run through the loop and set the last empty item to true, even though all inputs are empty. In my mind, I thought it should set everything that's empty to true, but looks like the loop will only recognize the last iteration. </p>
  
  <p>How do I setState to true for all inputs that are empty? </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form noValidate onSubmit={this.handleSubmit}&gt;
    &lt;label&gt;Name&lt;/label&gt;
    &lt;input className="form-input" type="text" name="name"&gt;
  
    &lt;label&gt;Email&lt;/label&gt;
    &lt;input className="form-input" type="text" name="email"&gt;
  
    &lt;label&gt;Message&lt;/label&gt;
    &lt;input className="form-input" type="text" name="message"&gt;
  &lt;/Form&gt;
  </code></pre>
  
  <p>State:</p>
  
  <pre><code>this.state = {
    errors: {
      name: false,
      email: false,
      message: false,
    },
  };
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>handleSubmit = (e) =&gt; {
  
  let inputFields = document.getElementsByClassName('form-input');
  
  for (var i = 0; i &lt; inputFields.length; i++) {
    if (inputFields[i].value === '') {
  
      let inputName = inputFields[i].name;
  
      this.setState({
        errors: {
          [inputName]: true,
        },
      });
    }
  }
  
  }
  </code></pre>