-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested IndexRoute not working #1950
Comments
That doesn't make sense, index routes are leaf nodes, can't be nested. |
@ryanflorence Sorry about writing to the closed issue. Like this: (Here <Route path="/" component={App}>
<IndexRoute component={Authorized}>
<IndexRoute component={Feed}/>
</IndexRoute>
<Route path="login" component={Login}/>
</Route> Another way to accomplish the desired behavior would be using just <Route path="/" component={App}>
<Route component={Authorized}>
<Route component={Feed}/>
</Route>
<Route path="login" component={Login}/>
</Route> But actually this is just the same as using |
<Route path="/" component={App}>
<Route component={Authorized}>
<IndexRoute component={Feed} />
</Route>
<Route path="login" component={Login}/>
</Route> Does that make sense? We can follow up on Reactiflux or Stack Overflow - the issue tracker is not great for this sort of Q&A thing. |
This seems like a valid issue. @taion's solution does not solve the problem. |
Elaborate? |
Maybe I am just confusing myself, but the discrepancies between the following cases are not intuitive: This works:
This does not work:
This also does not work, but I think semantically captures what I am trying to do and should be supported:
|
Should be <Route path="/" component={App}>
<Route component={Authorized}>
<IndexRoute component={Feed} />
...
</Route>
<Route component={LoginLayout}>
<Route path="login" component={Login} />
...
</Route>
</Route> |
Your second example doesn't work because it's trying to express You're really close. Here's what you need: <Route path="/" component={App}>
<Route component={Authorized}>
<IndexRoute component={Feed} />
</Route>
<Route component={LoginLayout}>
<Route path="login" component={Login} />
<Route path="forgot_password" component={ForgotPassword} />
</Route>
</Route> Edit: What @taion said. |
ah makes sense, thanks guys. |
I believe I have found a case where nested routes for |
I just commented over there. |
@taion @ryanflorence Thank you both for clarification. |
@timdorr I appreciate (and I'm using) the solution you gave. However it seems somewhat non-intuitive to me that a |
It lets you handle cases like #3326 (comment) cleanly. |
@taion aha, interesting discussion. Thanks for sharing. |
Yeah, so it's nothing conceptual and at some level it's a bit sloppy, but in practice it's really convenient for certain kinds of route definitions. |
I have this route setup, where I need nested IndexRoutes
But the inner
IndexRoute
doesn't ever seem to resolve.The text was updated successfully, but these errors were encountered: