title: Push() is not working in react
body: <p>I am newbie in Reactjs. I am making a form in which form data will store in an array and shows on same page after submission. I am using push() to store data in array but when I press submit button then error encountered:</p>
  
  <blockquote>
    <p>Cannot read property 'push' of undefined</p>
  </blockquote>
  
  <p>I am unable to store data in array. and Here is my code snippet:</p>
  
  <pre><code>import React from "react";
  data = [{ firstName :'', lastName:'', username:'' }];
  
  export default class Form extends React.Component {
  
    state = {
      firstName: "",
      lastName: "",
      username: ""
    }
  
    change = e =&gt; {
      this.props.onChange({ [e.target.name]: e.target.value });
      this.setState({
        [e.target.name]: e.target.value
      });
    };
  
    onSubmit = e =&gt; {
      e.preventDefault();
      console.log(this.state);
  
      let firstName = this.state.firstName.value;
      let lastName = this.state.lastName.value;
      let username = this.state.username.value; 
  
  
      this.setState({
        data :  this.state.data.push({firstName, lastName, username})
      })
  
  
    render() {
      return (
        &lt;form&gt;
          //Form Fields
       )
      }
  </code></pre>
  
  <p>I want help regarding this. Thanks a lot!!!</p>