So, let's say I have Profile page which renders different components according to the path. For example:
/profile/posts renders Posts component inside Profile.
/profile/comments renders Comments component inside Profile.
I normally first render Profile page for "/profile" path and then inside it, render relevant Component according to the Routes mentioned above. What I would like to do is, omit the "/profile" part of the paths defined in Route components inside Profile and only keep the remaining part. How can that be done by not breaking the routing ?
See the comments in the code below:
// App.js
// ...
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route path="/profile"> // Profile page is rendered here
<Profile />
</Route>
</Switch>
// ...
// Profile.js
// ...
<Switch>
<Route exact path="/profile/posts"> // I want to omit "/profile" part of the path.
<Posts />
</Route>
<Route path="/profile/comments"> // I want to omit "/profile" part of the path.
<Comments />
</Route>
</Switch>
// ...