title: Uncaught TypeError: Cannot read property 'value' of undefined in REACT JS
body: <p>I am creating a login form using REACT JS as front-end and PHP as back-end. I am trying to get input values. Code is as below:</p>
  
  <pre><code>import React, { Component} from 'react';
  import ReactDOM from 'react-dom';
  import {Button, IconButton} from 'react-toolbox/lib/button';
  import Input from 'react-toolbox/lib/input';
  
  export default class Login extends React.Component {
  
  constructor() {
      super();
      this.state = {email: ''};
      this.state = {password: ''};
      this.onSubmit = this.onSubmit.bind(this);
      this.handleEmailChange = this.handleEmailChange.bind(this);
      this.handlePasswordChange = this.handlePasswordChange.bind(this);
  }
  handleEmailChange(e) {
      this.setState({email: e.target.value});
  }
  handlePasswordChange(e) {
      this.setState({password: e.target.value});
  }
  onSubmit() {
      fetch('http://xyz/check-login', {
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          email: this.state.email,
          password: this.state.password,
        })
      })
  }
  </code></pre>
  
  <p>And form is as below:</p>
  
  <pre><code>&lt;form name="Login"&gt;
  &lt;Input type="text" name="email" value={this.state.email} placeholder="Email Id" className="form-control" onChange={this.handleEmailChange} /&gt;
  &lt;Input name="password" value={this.state.password} placeholder="Password" type="password" className="form-control m-b-10" onChange={this.handlePasswordChange} /&gt;   
  &lt;Button type="button" className="m-t-20 orange" label="Sign in " onClick={this.onSubmit} /&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>But getting the following error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'value' of undefined</p>
  </blockquote>
  
  <p>I am using react-toolbox. So, I am using  component from <a href="https://github.com/react-toolbox/react-toolbox/blob/dev/components/input/Input.js" rel="noreferrer">https://github.com/react-toolbox/react-toolbox/blob/dev/components/input/Input.js</a> and  component from <a href="https://github.com/react-toolbox/react-toolbox/blob/dev/components/button/Button.js" rel="noreferrer">https://github.com/react-toolbox/react-toolbox/blob/dev/components/button/Button.js</a>.</p>