how to <Link> to a nested route?
<Route name='a'>
<Route name='b' />
</Route>
I want to <Link to='a/b'> but that doesn't work. to='b' doesn't work either. I get Unable to find <Route name="b">. What am I missing?
I realized I can't use a nested route under a DefaultRoute. So then how do I have a default route?
Are you trying to redirect? DefaultRoute matches its parent's path, so it becomes the RouteHandler in the parent's render.
On Wednesday, February 4, 2015, Travis Webb [email protected] wrote:
I realized I can't use a nested route under a DefaultRoute. So then how do I have a default route?
— Reply to this email directly or view it on GitHub https://github.com/rackt/react-router/issues/772#issuecomment-72985859.
Let's say we have the following configuration :
<Route name="app" handler={App}>
<Route name="user" handler={User}>
<Route name="profile" handler={Profile} />
</Route>
<Route>
How can we provide a default route from /to /user/profile?
@salper Does <Redirect from='/' to='/user/profile' /> help? I'm not sure if it's idiomatic way of doing that though.
@gaearon Well, that was the main (hidden) question. I wanted to know if there was a way to do so using DefaultRoute component. I'll go with the Redirect one til something idiomatic comes up. Thx.
To me it sounds like redirection is exactly what you're looking for.
How can we provide a default route from /to /user/profile?
The way I see it, DefaultRoute is not meant to affect your URLs in any way, or allow you to show the same content for different urls, but to give your parent routes a default RouteHandler in case they match the url exactly (and no child route does). A bit like index.html on webservers.
If you really wanted to use the same handlers for / and /user/profile, I think you could simply use routes with path="/":
<Route name="app" path="/" handler={App}>
<Route name="user-index" path="/" handler={User}>
<Route name="profile-index" path="/" handler={Profile} />
</Route>
<Route name="user" handler={User}>
<Route name="profile" handler={Profile} />
</Route>
<Route>
That sounds pretty well to me, thx.