Answers for "react redirect page"

50

redirect react js

window.location.href = "http://mywebsite.com/home.html";
Posted by: Guest on July-18-2019
2

programmatically redirect react router

import { useHistory } from "react-router-dom";

function HomeButton() {
  const history = useHistory();

  function handleClick() {
    history.push("/home");
  }

  return (
    <button type="button" onClick={handleClick}>
      Go home
    </button>
  );
}
Posted by: Guest on February-15-2020
8

react redirect to url

import { Route, Redirect } from 'react-router'

<Route exact path="/" render={() => (
  loggedIn ? (
    <Redirect to="/dashboard"/>
  ) : (
    <PublicHomePage/>
  )
)}/>
Posted by: Guest on July-20-2020
6

how to redirect react router from the app components

state = { redirect: null };

render() {
  if (this.state.redirect) {
    return <Redirect to={this.state.redirect} />
  }
  return(
  // Your Code goes here
  )
}

// update the redirect
 this.setState({ redirect: "/someRoute" });
Posted by: Guest on June-08-2020
0

redirect to in react js

<Route exact path="/">
  {loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
</Route>
Posted by: Guest on November-15-2020
3

how to redirect react router from the app components

state = { redirect: null };
render() {
  if (this.state.redirect) {
    return <Redirect to={this.state.redirect} />
  }
  return(
  // Your Code goes here
  )
}
Posted by: Guest on June-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language