How to redirect after success from ajax call using React-router-component?

后端 未结 3 1272
臣服心动
臣服心动 2021-02-14 10:23

I am building a application using Facebook flux architecture of React JS. I have build the basic part of app where I have a login form. I am fetching t

3条回答
  •  梦谈多话
    2021-02-14 10:41

    It worked for me when I added to the react element properties a require for the router and used the router like this:

    // this is the redirect
        this.context.router.push('/search');
    
    // this should appear outside the element
        LoginPage.contextTypes = {
            router: React.PropTypes.object.isRequired
        };
        module.exports = LoginPage;
    

提交回复
热议问题