score:0

Accepted answer
function SignIn() {
  const history = useHistory();

  const [userEmail, setEmail] = useState("");
  const [userPassword, setPassword] = useState("");

  //after onClick
  const signIn = (e) => { // <-- onSubmit event object
    e.preventDefault();   // <-- preventDefault
    // get user input
    Axios.post("http://localhost:8800/signIn", {
      userEmail: userEmail,
      userPassword: userPassword
    }).then((res) => {
      console.log(res);
      history.push("/clientprofile");
    });
  };

  return (
    <Form onSubmit={signIn}> // <-- onSubmit event handler
      ...

      <Button variant="primary" type="submit"> // <-- remove onClick handler
        Submit
      </Button>
    </Form>
  );
}

score:0

useEffect(()=>{

if(isRedirect){
    history.push('/clientprofile');
}

},[isRedirect,history])

score:0

import { useNavigate } from 'react-router-dom';

const signIn = () => {
  ....

  let navigate = useNavigate();

         .....
         ......

      navigate('/clientprofile');
    
    .....

  }

Related Query

More Query from same tag