0

Trying to implement redirect after login success. history.pushState(null,null, '/profile') doesn't work. Just change URL and all. browserHistory.push('/profile'); Same

How do i can create redirect after login?

        case types.LOG_IN_SUCCESS:
        history.pushState(null,null, '/profile');

Thanks

Андрей Гузюк
  • 2,134
  • 6
  • 29
  • 53

2 Answers2

0

React Router has replace method instead of transitionTo for redirects. If you have some old version of Router you may need to use transitionTo.

Check this from Michelle Tilley.


I think in your case you may use (no need for this depends on the version you have):

var Router = require('react-router');
Router.browserHistory.push('/somepath');
Community
  • 1
  • 1
prosti
  • 42,291
  • 14
  • 186
  • 151
0

You need to call the push method on the router:

this.context.router.push('/profile');

In case you need router in your Login component - if you add this you will have router.

LoginComponent.contextTypes = {
    router: React.PropTypes.object.isRequired
};
flexicious.com
  • 1,601
  • 1
  • 13
  • 21