title: A component is changing an uncontrolled input of type email to be controlled. Input elements should not switch from uncontrolled to controlled
body: <p>I am getting this error, I am new in react. I have seen other posts but still could not resolve the issue. help will be appreciated. thanks</p>
  
  <blockquote>
    <p>Warning: A component is changing an uncontrolled input of type email to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info
        in input (created by Edit)
        in div (created by Edit)
        in div (created by Edit)
        in form (created by Edit)
        in div (created by Edit)
        in Edit</p>
  </blockquote>
  
  <pre><code>import React from 'react'
  import ReactDom from 'react-dom'
  
  export default class Edit extends React.Component{
      constructor(){
          super();
          this.state={
              name: '',
              email: '',
              password: '',
          };
  
      }
  
  componentWillMount(){
      let id=this.props.id;
      axios.get('/api/users/'+id).then(response =&gt; {
          var user= response.data;
  
          this.setState({
              name: user.name,
              email: user.email,
          })
      }).catch(error =&gt; {
          console.log(error)
      })
  }
  
  handleNameChange(e){
      this.setState({
          name: e.target.value
      })
  }
  
  handleEmailChange(e){
      this.setState({
          email: e.target.value
      })
  }
  
  handlePasswordChange(e){
      this.setState({
          password: e.target.value
      })
  }
  
  handleSubmit(e){
      e.preventDefault();
      console.log(this.state)
  
      axios.post('/api/users',this.state).then(response =&gt; {
          console.log(response)
      }).then(error =&gt; {
          console.log(error)
      })
  }
  
      render(){
          return(
              &lt;div&gt; 
              &lt;h2&gt; Add New User &lt;/h2&gt;
  
  
              &lt;form className="form-horizontal" onSubmit={this.handleSubmit.bind(this)}&gt;
                   &lt;div className="form-group"&gt;
                      &lt;label className="control-label col-sm-2" htmlFor="email"&gt;Name:&lt;/label&gt;
                      &lt;div className="col-sm-10"&gt;
                        &lt;input type="text" className="form-control" id="name" placeholder="Enter name" value={this.state.name}
                         onChange={ this.handleNameChange.bind(this) }/&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
  
                    &lt;div className="form-group"&gt;
                      &lt;label className="control-label col-sm-2" htmlFor="email"&gt;Email:&lt;/label&gt;
                      &lt;div className="col-sm-10"&gt;
                        &lt;input type="email" className="form-control" id="email" placeholder="Enter email" value={this.state.email}
                         onChange={ this.handleEmailChange.bind(this) }/&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
  
                     &lt;div className="form-group"&gt;
                      &lt;label className="control-label col-sm-2" htmlFor="email"&gt;Password:&lt;/label&gt;
                      &lt;div className="col-sm-10"&gt;
                        &lt;input type="password" className="form-control" id="password" placeholder="Enter password" value={this.state.password}
                          onChange={ this.handlePasswordChange.bind(this) }/&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
  
                  &lt;div className="form-group"&gt;
                      &lt;button type="submit" className="btn btn-default"&gt;Update&lt;/button&gt;   
                  &lt;/div&gt;
  
  
          &lt;/form&gt;
  
          &lt;/div&gt;
              )
          }
  }
  
  if (document.getElementById('edit')) {
      var id=$("#edit").data("id");
  ReactDom.render(&lt;Edit id={id}/&gt;, document.getElementById('edit'))
  }
  </code></pre>