score:0

handleSubmit(e) {
        e.preventDefault();

        //const history = useHistory();
        this.setState({ submitted: true });
        const { username, password } = this.state;
        const { dispatch } = this.props;
        let errors = {};

        if (username == "admin" && password == "admin") {

            props.history.push('/dashboard');
            console.log("Logged-in");

        } else {

            errors["credentials"] = "You have entered the wrong username or password.";

        }

        this.setState({
            errors: errors
        });

    }

score:0

<Route to="login" component={login}/>

score:1

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

...

export default withRouter(Login);

Related Query

More Query from same tag