title: How to automatically click submit button - react
body: <p>I have a react login page with username and password manually inputted,</p>
  <p>I want the submit button to automatically click upon page load so it will automatically log in users.</p>
  <p>Here is my code.</p>
  <pre><code>
  export const LoginForm = () =&gt; {
      const history = useHistory();
      const classes = useStyles();
      const email = 'email@email.com';
      const password = 'mypassword';
      const [authStatus, setStatus] = useState(null);
      const [isSpinnerHidden, setSpinner] = useState(true);
      const { session } = useContext(SessionContext);
  
      const recaptchaRef = useRef();
  
      const _onSubmit = async (e) =&gt; {
          e.preventDefault();
          setSpinner(false);
  
          const authResult = await session.signIn(email, password);
          setSpinner(true);
          console.log(session);
          authResult ? setStatus(authResult) : history.push('/dashboard');
  
      };
  
      return (
          &lt;form onSubmit={_onSubmit}&gt;
              &lt;Typography
                  align='center'
                  color='primary'
                  variant=&quot;h4&quot;
                  style={{ marginBottom: '20px' }}
              &gt;
                  Sign In
              &lt;/Typography&gt;
              {authStatus ?
                  &lt;Alert
                      severity=&quot;error&quot;
                  &gt;
                      {authStatus}
                  &lt;/Alert&gt;
                  :
                  null
              }
              &lt;TextField
                  type='email'
                  label=&quot;Email&quot;
              /&gt;
              &lt;TextField
                  type='password'
                  label=&quot;Password&quot;
              /&gt;
              &lt;Link
                  onClick={() =&gt; history.push('/restore')}
                  className={classes.restore}&gt;
                  Forgot password?
              &lt;/Link&gt;
  
              
              &lt;MuiButton
                  text='Sign In'
                  type='submit'
                  value='login'
                  isSpinnerHidden={isSpinnerHidden}
                  className={classes.button}
              /&gt;
          &lt;/form&gt;
  
          
      );
  };
  </code></pre>
  <p>what can I add to this code or change that will make it click on the sign-in button automatically and login the user.</p>