Muyinda Rogers
Muyinda Rogers

Reputation: 157

React Router Conflicts two routes

Below is my attached routes, When I navigate to /login/schoolname. I get the correct component, but when I navigate to the verify, it appends onto /login/verify.

<Switch> 
  <Route path="/verify" component={Verify} />
  <Route path="/login/:schoolName" component={Login} />
  <Route path="*" component={Home} />
</Switch>

I was expecting, some thing like localhost/verify localhost/login/schoolname whenever I click on the navigation

Upvotes: 2

Views: 425

Answers (1)

Karim
Karim

Reputation: 8632

change the route in order to match the path exactly

<Route exact path="/verify" component={Verify} />

and when you manually change the route be sure to put the slash in the front of the route name

history.push("/verify");

Upvotes: 5

Related Questions