-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add "default route" handler #164
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
Comments
A few variations on this same idea: 1 Use a <Route path="users/:userID" handler={User} defaultRouteHandler={Details}>
<Route path="users/:userID/activity" handler={Activity}/>
</Route> 2 Move <Route path="users/:userID" handler={User}>
<Route path="users/:userID/activity" handler={Activity}/>
<!-- A DefaultRoute magically gets its parent's path -->
<DefaultRoute handler={Details}/>
</Route> 3 Use a <Route path="users/:userID" handler={Details} layoutHandler={User}>
<Route path="users/:userID/activity" handler={Activity}/>
</Route> 4 Use a <Layout path="users/:userID" handler={User}>
<Route path="users/:userID" handler={Details}>
<Route path="users/:userID/activity" handler={Activity}/>
</Layout> AFAICT, these would all work exactly the same. Only difference is readability/documentation. |
Looking at no. 2 makes me wonder if all Edit: It would also let us reduce no. 4 to this: <Layout path="users/:userID" handler={User}>
<Route path="users/:userID/activity" handler={Activity}/>
<Route handler={Details}>
</Layout> |
I like |
Here's the implementation for Router.DefaultRoute = Router.Route; |
haha, alright, lets do the no-name-inherit, and if it gets confusing, we'll bring in that amazing component. |
s/gets confusing/if we find we are explaining how to use it a lot/ |
note, this will require a version bump since an omitted path means something different |
👍 |
The only reason I don't like Should we make an exception in this case? Would that be confusing? Edit: I should mention that I believe traversing the routes in order is a pretty great thing. It helps a lot with readability and debugging. If we start making exceptions to that rule, we need to be very explicit about it. |
You're right, I would expect to be able to place it before or after any sibling, I think the exception is fine here. <Route>
<Route/>
<DefaultRoute/>
<Route/>
</Route>
<Route>
<DefaultRoute/>
<Route/>
<Route/>
</Route>
<Route>
<Route/>
<Route/>
<DefaultRoute/>
</Route> |
Yeah, I think I know a clean way to do it. Need to play around with it a little. |
Proposal:
<Route defaultRouteHandler>
specifies a route handler that is rendered when a route matches on the path but none of its children do. It is akin to Ember's "index" routes and gives us a declarative way to specify a default handler for a route instead of usingYou use it like this.
In addition, when a route uses
defaultRouteHandler
, the value ofthis.props.activeRouteHandler
should automatically use it so the user can writeinstead of
The text was updated successfully, but these errors were encountered: