Stack Exchange
× TypeError: Cannot read property 'history' of undefined
Logged in User, But Redirect doesn't work. How to solve these issues? Here is the
Login components code:
const Login = ({ props }) => {
    const [email, setEmail] = useState();
    const [password, setPassword] = useState();

    const alert = useAlert();
    const dispatch = useDispatch();

    const { isAuthenticated, error, loading } = useSelector(
      (state) => state.auth
    );

    useEffect(() => {
      if (isAuthenticated) {
        props.history.push("/");
      }

      if (error) {
        alert.error(error);
        dispatch(clearErrors());
      }
    }, [dispatch, alert, error, loading, props, isAuthenticated]);

    const submitHandler = (e) => {
      e.preventDefault();
      dispatch(login(email, password));
    };  
    return ()
}

Error:
TypeError: Cannot read property 'history' of undefined


({ props }) => { ----> ( props ) => {

you destructure props from props? Maybe you meant ({ history, aProp, bProp }) ?
