title: React form, to submit object which is then pushed to array
body: <p>I'm new to React and unsure about how to do this.</p>
  
  <p>I have an array of objects that I have mapped through and rendered in my view. What I want to do is set up a form that will submit the values of each field to the corresponding properties of a new object, but I'm not sure how to go about doing this.</p>
  
  <p><strong>Here is my initial data, which is rendered in the view:</strong></p>
  
  <pre><code>contactArray = [
    {
      name: 'John'
      email: 'john@email.com'
      number: 111-111-111
    },
    {
      name: 'Dave'
      email: 'dave@email.com'
      phone: '222-222-222'
    }
  ]
  </code></pre>
  
  <p><strong>Then I have a form:</strong></p>
  
  <pre><code>class InputForm extends Component {
    render() {
      return (   
          &lt;form&gt;
            &lt;input type='text' onChange={this.handleChange}/&gt;
            &lt;input type='text' onChange={this.handleChange}/&gt;
            &lt;input type='text' onChange={this.handleChange}/&gt;
            &lt;button type='submit' onSubmit={this.handleSubmit}&gt;SUBMIT&lt;/button&gt;
          &lt;/form&gt;
      ) 
    }
  </code></pre>
  
  <p><strong>Then I assume I declare the state as this:</strong></p>
  
  <pre><code>constructor(props) {
    super(props);
    this.state = {
      name: '',
      email: '',
      phone: ''
    }
  }
  </code></pre>
  
  <p><strong>Then the submission function I don't really know how to handle...</strong></p>
  
  <pre><code>handleSubmit() {
    // not sure about this...
    this.setState({
      name: // ????
      email: // ????
      phone: // ????
    })
  }
  </code></pre>
  
  <p>And then I want to clear the submit form, as well as the object that is used to push the new object, which is now in the array (I hope that makes sense...)</p>
  
  <p>So, I'm not even sure how to use state in this scenario, but ultimately I want to <code>push()</code> the new object to the array that is rendered, with all the properties as they were completed in the form.</p>
  
  <p>Sorry I can't be more complete with my working up to this point, but would at least appreciate some pointers on this!</p>