0

So first this is my code :

const SignIn = (e) => {
      e?.preventDefault()
      if(usernamePattern?.test(this.state.userLoginInfo.username) && emailPattern?.test(this.state.userLoginInfo.email) && passwordPattern?.test(this.state.userLoginInfo.password)) {
        this.setState({...userLoginInfo.isLoggedIn = true})
        storeUserInfo(userLoginInfo);
      }
      if(usernamePattern?.test(userLoginInfo.username) == false){
        usernameErrMsg?.classList.remove('hidden')
        usernameInputBorder?.classList.remove('border-slate-500');
        usernameInputBorder?.classList.add('border-red-600');
      }
      if(emailPattern?.test(userLoginInfo.email) == false){
        emailErrMsg?.classList.remove('hidden')
        emailInputBorder?.classList.remove('border-slate-500');
        emailInputBorder?.classList.add('border-red-600');
      }
      if(passwordPattern?.test(userLoginInfo.password) == false){
        passwordErrMsg?.classList.remove('hidden')
        passwordInputBorder?.classList.remove('border-slate-500');
        passwordInputBorder?.classList.add('border-red-600');
      }
    }

I want to redirect to the '/dashboard' route when the user signs in with the correct info. is there an alternative for 'useNavigate' in class components ? note: {browserHistory} did not work for me.

4

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.