0
Q:

redirect to in react js

window.location.href = "http://mywebsite.com/home.html";
34
<Route exact path="/">
  {loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
</Route>
1
import { useHistory } from "react-router-dom";

function App() {
  let history = useHistory();
}
0
// Sets the new location of the current window.
window.location = "https://www.test.com";

// Sets the new href (URL) for the current window.
window.location.href = "https://www.test.com";

// Assigns a new URL to the current window.
window.location.assign("https://www.test.com");

// Replaces the location of the current window with the new one.
window.location.replace("https://www.test.com");

// Sets the location of the current window itself.
self.location = "https://www.test.com";

// Sets the location of the topmost window of the current window.
top.location = "https://www.test.com";
-2

New to Communities?

Join the community