title: Warning: A component is changing a controlled input to be uncontrolled in React js
body: <p>HELP. i use react hook, i got the error when i type the input.</p>
  <p>error:</p>
  <blockquote>
  <p>Warning: A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component.</p>
  </blockquote>
  <p>Code:</p>
  <pre><code>const AddUser = () =&gt; {
  const initialUserState = {
      id: null,
      name: '',
      age: 0
  }
  
  const [users, setUsers] = useState(initialUserState)
  
  const handleChange = (e) =&gt; {
      setUsers({ [e.target.name]: e.target.value })
  
      e.preventDefault()
  }    
  
  return (
      &lt;div&gt;
          &lt;input name=&quot;name&quot; type=&quot;text&quot; value={users.name} onChange={handleChange}/&gt;
          &lt;input name=&quot;age&quot; type=&quot;number&quot; value={users.age} onChange={handleChange}/&gt;
      &lt;/div&gt;
  )}
  </code></pre>