React Router v4 Redirect not working

前端 未结 6 1510
北恋
北恋 2020-12-13 04:17

I have a route which redirects after checking a condition like this

(
Store.isFirstTime ? 

        
6条回答
  •  佛祖请我去吃肉
    2020-12-13 04:55

    you can try this way like:

    first: import "withRouter" to component like this:

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

    then at the end of your component export compoenent like this:

    export default withRouter(VerifyCode);
    

    and then you can add this code to your function:

     verify(e) {
        // after sever get 200
        this.props.history.push('/me/');
    }
    

    good luck

提交回复
热议问题