Intermundos
Intermundos

Reputation: 561

React router: Location did not match any routes

Can someone help me with following issue:

<Route path="/" component={ App } >
    <Route path="posts/(:id)" component={ PostsIndex } />
    <Route path="admin" component={ Admin } />
</Route>

When I add dynamic routing (:id), I get an error: [react-router] Location "/posts" did not match any routes.

I delete the (:id) and everything just works fine.

Your help is much appreciated

Upvotes: 1

Views: 1521

Answers (1)

Cobuz Alexandru
Cobuz Alexandru

Reputation: 322

<Route path="/" component={ App } >
    <Route path="posts" component={ PostsIndex }>
         <Route path="posts/:id" component={ PostsIndex } />
    </Route>
    <Route path="admin" component={ Admin } />
</Route>

Nested routes should help in this case.

Upvotes: 2

Related Questions