-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[added] <DefaultRoute> component #200
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
Conversation
* Only one such route may be used at any given level in the | ||
* route hierarchy. | ||
*/ | ||
function DefaultRoute(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need @spicyj to show us how to do this properly before the next release of react, apparently we are cheating here and need to make components, not just functions that can trick JSX, but for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you by chance mean that something like <Route to='somewhere' handler={ShellHandler} defaultHandler={DefaultHandler} />
would be more correct instead? Definitely easer then doing checks to make sure there is only one DefaultRoute
child.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean how do we make a real component out of <DefaultRoute/>
instead of just a function that jsx thinks is a component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks for the clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can imagine that <DefaultRoute handler={Foo} />
will be compiled into {type: DefaultRoute, props: {handler: Foo}}
. I am pretty sure that RegisterRoute will just have to understand what DefaultRoute is.
crap, I messed this all up by merging 6d1ae95 |
@mjackson is it intentional that you now have to specify <Routes>
<Route handler={App}>
<DefaultRoute handler={Index}/>
...
</Route>
</Routes> Doesn't work anymore. I thought maybe I needed to use <Routes>
<DefaultRoute handler={App}>
<DefaultRoute handler={Index}/>
...
</DefaultRoute>
</Routes> But that doesn't work either. |
oh, I see now that it was intended for this to fix #193 ... anyway, I rebased with master, this branch no longer has conflicts. |
No, that's not intentional if it's true, but it shouldn't be. You should still be able to leave the path off as usual. Root routes get |
yeah, I already merged that, but have rebased this commit with master and removed it, all is well. |
Doesn't work. I had to add this: https://github.com/rackt/react-router/pull/200/files#diff-cfa924f8d5ffb353e9d877f0273257efR51 |
ok, it does now. I've updated the examples and fixed the bug. I'll let you merge when you think it's ready. |
[added] <DefaultRoute> component
FWIW,I found that the |
Also, changed behavior of routes with no name, path, or children so
they act as default routes. is essentially just sugar.
Fixes #164
Fixes #193