Emmathem
Emmathem

Reputation: 103

Route Naming in React Js

**Working Routes**
<Route path="/moversng" component={AppMoverLandingPage} />
<Route path="/movers-ng/dashboard/login" component={AppMoverLogin} />
<Route path="/movers-ng/dashboard" component={AppDashboard} />
<Route path="/movers-ng/manage-users" component={AppManageUsers} />
**What I wanted but not working**
<Route path="/moversng" component={AppMoverLandingPage} />
<Route path="/moversng/dashboard/login" component={AppMoverLogin} />
<Route path="/moversng/dashboard" component={AppDashboard} /> - *Worked*
<Route path="/moversng/dashboard/manage-users" component={AppManageUsers} /> - *Not working*

Question: Are they conventional ways of route naming against your folder name? From what I wanted routes, with those naming, the component/page will not render but retained the previous page.

What am I doing wrongly?

Thanks.

Upvotes: 0

Views: 3041

Answers (2)

Mohammad Mohammadi
Mohammad Mohammadi

Reputation: 305

try work with exact for example:

<Route path="/" component={Home} exact/>
<Route path="/about" component={About} />
<Route path="/login" component={Login} />

Upvotes: 0

T J
T J

Reputation: 43156

Try adding exact to your routes, without it the routes are being considered child routes:

<Route path="/moversng" exact component={AppMoverLandingPage} />
<Route path="/moversng/dashboard/login" exact component={AppMoverLogin} />
<Route path="/moversng/dashboard" exact component={AppDashboard} /
<Route path="/moversng/dashboard/manage-users" exact component={AppManageUsers}/>

Upvotes: 1

Related Questions