“Redirect React Router” Kode Jawaban

Redirect React JS

window.location.href = "http://mywebsite.com/home.html";
Grepper

bereaksi mengalihkan ke URL

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

<Route exact path="/" render={() => (
  loggedIn ? (
    <Redirect to="/dashboard"/>
  ) : (
    <PublicHomePage/>
  )
)}/>
Testy Tuatara

React Router Redirect

<Route exact path="/">
  {loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
</Route>
Wicked Walrus

Redirect React Router

<Route exact path="/">
  {loggedIn ? <Redirect to="/profile" /> : <HomePage />}
</Route>
Kaotik

REACT-ROUTER-DOM RERIRECT

<Route path="/somePath" element={<Navigate replace to="/" />} />
Gor Baghramyan

cara mengarahkan kembali router bereaksi dari komponen aplikasi

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" });
Salo Hopeless

Jawaban yang mirip dengan “Redirect React Router”

Pertanyaan yang mirip dengan “Redirect React Router”

Lebih banyak jawaban terkait untuk “Redirect React Router” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya