DEV Community

Kamikaze
Kamikaze

Posted on

How to Redirect After Login

I have this code:
BrowserRouter
Switch
Redirect from="/" exact to={verificarLogueo ? "/dashboard" : "/login"} /

  Route exact path="/login" component={Login} /
  Route exact path="/dashboard" component={Dashboard} /
/Switch

/BrowserRouter

How to redirect at my Dashboard Component after Login using Router when verificarLogueo change the value at true?

Top comments (2)

Collapse
 
kamikazeve profile image
Kamikaze

HowtoRedirectAfterLogin

Collapse
 
arpitmalik profile image
Arpit Malik • Edited

Add history.push("/dashboard") when login action returns success