title: problem in updating state using useState hook
body: <p>I am using useSatate for managing my form errors:</p>
  
  <pre><code>const [formErrorObj, updateForErrormObj] = useState({
          name_error: '',
          email_error: '',
          contact_number_error: '',
          username_error: '',
          password_error: '',
          promo_mail_error: ''
      })
  </code></pre>
  
  <p>and this is where I am creating object with all form errors:</p>
  
  <pre><code>function onSubmitHandler(event) {
          event.preventDefault();
          const error = validate();
          if (error) {
          const errorList = error.error.details;
          const newErrorObj = {};
          for (let err in errorList) {
              newErrorObj[error.error.details[err].context.key + '_error'] = error.error.details[err].message
  
          }
          updateForErrormObj({ ...formErrorObj, ...newErrorObj })
  
          console.log(newErrorObj, formErrorObj)
      }
  }
  </code></pre>
  
  <p>Newly created object looks something like this :</p>
  
  <pre><code>contact_number_error: ""Contact Number" is not allowed to be empty"
  email_error: ""Email" must be a valid email"
  name_error: ""Username" is not allowed to be empty"
  password_error: ""Password" length must be at least 5 characters long"
  username_error: ""Username" is not allowed to be empty"
  __proto__: Object
  </code></pre>
  
  <p>After validation when I try to update state using :</p>
  
  <pre><code>updateForErrormObj({ newErrorObj }) // try 1 
  updateForErrormObj(newErrorObj) // try 2
  updateForErrormObj({ ...formErrorObj, ...newErrorObj }) // try 3
  </code></pre>
  
  <p>no try from three works form me.
  I am not sure what I am doing wrong here.</p>