title: React hooks setState not updating immediately
body: <p>I am trying to validate field when I click on submit button. This is how I defined my state.</p>
  
  <pre><code>  const [values, setValues] = useState({
      email: "",
      password: "",
      emailErrorMessage: "",
      passwordErrorMessage: "",
      errorMessage: "",
      emailError: false,
      passwordError: false,
      rememberMe: false,
    });
  </code></pre>
  
  <p>In submit method, this is how I am validating it.</p>
  
  <pre><code>if (values.email.length &lt;= 0) {
  
    setValues({
      ...values,
      emailError: true,
      emailErrorMessage: "Email field must not be empty"
    })
  };
  
  if (values.password.length &lt;= 0) {
    setValues({ ...values, passwordError: true, passwordErrorMessage: "Password field must not be empty" });
  }
  </code></pre>
  
  <p>For somehow it is only showing me error for password field. Although it is going through both the if conditions. Not sure how exactly I can Fix it.</p>
  
  <p>Expected:- it should show error for both email and password.</p>