React logs in with fetch, how to jump to the component after success

1. After the login is successful, the data returned by the backend is sent to the data of fetch, and then how to use routing to jump to other components
2. If routing is not needed, can I use window.location.href to jump to the component
handleSubmit = (e) = > {

    e.preventDefault();
    // let history = this.context.router.history;
    this.props.form.validateFields((err, values) => {
        if (!err) {
            fetch("/api/login",{
                method:"POST",
                headers: {
                    "Accept": "application/json",
                    "Content-Type":"application/json;charset=UTF-8"
                },
                body:JSON.stringify({"email":values.email,"password":values.password}),
            }).then(function (res) {
                return res.json();
            }).then(function(data){
                console.log(data)
                // window.location.href="/usercenter";
             
                }
            ).catch(function (err) {
                console.log(err);
            })
        }
    });
}
Mar.02,2021

if you don't use routing, you can bring in the component to be redirected, and then replace the current component with
after the fetch is successful, put the data into state, and then under render, if determines that different components are displayed according to the data


    import { withRouter } from 'react-router-dom';  // react-routerreact-router4withRouterhistoryhistory
    this.props.history.push('/usercenter');
.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30878-2bd24.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30878-2bd24.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?