React-router: Redirect to different domain url.

Created on 28 Jun 2015  路  5Comments  路  Source: ReactTraining/react-router

I am using react-router for client side routing. I have a button and when some one clicks that button, I want to redirect the user to a different url. For e.g I want to redirect the user to "http://www.google.com". I used navigation mixin and used this.transitionTo("https://www.google.com"). But when I do this I get this error "Invariant Violation: Cannot find a route named "https://www.google.com"".
I may be doing something silly there. I can use window.location but is that the right way to go ?

Most helpful comment

Please assign the value of window.location as @taurose suggested. The router's navigation methods are only for your app, not the whole web.

All 5 comments

Is there a reason you're not using a regular anchor tag? <a href="https://www.google.com"></a>

transitionTo is only for internal URLs. Use window.location or <a href>.

I have a form and form can have multiple pages. I have next, back and submit button on the form. When user clicks the next and back button, I do the respective operation, but on submit, I can go to a third party url, or an internal app url depending upon the configuration.

In order to use transitionTo, i need to use the navigation mixin, is there any way i could avoid using the mixin?

@ransanjeev this.context.router.transitionTo ?

Please assign the value of window.location as @taurose suggested. The router's navigation methods are only for your app, not the whole web.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Waquo picture Waquo  路  3Comments

misterwilliam picture misterwilliam  路  3Comments

maier-stefan picture maier-stefan  路  3Comments

imWildCat picture imWildCat  路  3Comments

alexyaseen picture alexyaseen  路  3Comments