react router - Redirection after login

后端 未结 7 2209
天命终不由人
天命终不由人 2021-01-30 14:22

Could you please help me in understanding the redirection mechanism I could use with latest version of react router ( v1.1.0 ) . I would like to redirect to a

相关标签:
7条回答
  • 2021-01-30 14:54

    React Router v4.2

    I am using React-16.2 & React-router-4.2

    and I get solution by this this.props.history.push("/");

    My working code:

        .then(response => response.json())
            .then(data => {
                if(data.status == 200){
                    this.props.history.push("/");
                    console.log('Successfully Login');
              }
            })
    

    I was following this document redirect-on-login-and-logout

    0 讨论(0)
提交回复
热议问题