Reputation: 9625
I got the following routes in my app:
<div>
<Route exact path='/:category' render={() => (
<Posts/>
)}/>
<Route exact path='/' render={() => (
<Posts/>
)}/>
</div>
Where the second route is just an extension of the first and routes to the same component. How can I combine both routes in one Route tag?
Upvotes: 2
Views: 1194
Reputation: 1512
You can use <Route exact path='/:category?' component={Posts} />
what the question mark does is make the url extension an optional value.
Upvotes: 2