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 ?
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.
Most helpful comment
Please assign the value of
window.locationas @taurose suggested. The router's navigation methods are only for your app, not the whole web.