1

I am using react and react-router do we have any replacement of window.location.assign or any other window method for redirection in react or react-router? I want to redirect to some other website. Not on the same react website from which I am redirecting. I found this answer How to emulate window.location with react-router and ES6 classes but it is redirecting to some other page in the react application only so, this is not sufficient for me.

I am using react-router v4+

Aniruddh Agarwal
  • 900
  • 1
  • 7
  • 22

2 Answers2

0

I think you want to redirect third party URLs

location.assign(<Your URL>);

example:

location.assign("https://google.com")
rajkanani
  • 173
  • 3
  • 5
-1

Have you tried using the history package, after installing history package,

import createHistory from 'history/createBrowserHistory';

const history = createHistory();
history.push('www.abc.com');
history.go(0);
Shyam Kumar
  • 148
  • 9