-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Make Route more extensible #65
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
I'm not opposed to this, though it seems like #52 should be solved by using a |
To clarify, the var PostPage = React.createClass({
statics: {
paramsAreValid: function (params) {
// ...
},
willTransitionTo: function (transition, params) {
if (!PostPage.paramsAreValid(params))
transition.redirect('404');
}
}
}); Of course, this requires you to create your own But also, consider the case where |
Ignoring #52 (since it has been solved quite nicely with https://github.com/bjyoungblood/rnr-constrained-route) I still wonder if there's some interesting stuff we just aren't thinking about yet that could happen if people could make their own But until we have a strong use-case that can't be solved elegantly with the existing api, happy to leave this sitting here and pick it up then. |
@rpflorence Can you post an example how this could solve the context problem discussed in #57? |
var ContextualRoute = React.createClass({
mixins: [ Router.RouteMixin ],
getDefaultProps: function() {
return { context: { foo: 'bar' } }
}
}); <ContextualRoute handler={App}/>
<!-- instead of -->
<Route context={context} handler={App}/> |
I don't think we need to do anything fancy here anymore, the way we've implemented Unless @spicyj sees something terrible about treating a plain old function like a component ... I felt a little sneaky when I wrote that code. |
Actually, yes. Plain functions will soon cease to work in JSX because of a handful of changes we're planning to make soon – you'll hear more details from @sebmarkbage when they're ready. |
Would like to know how to accomplish what we have with |
For cases like #52 it would be lovely to provide interesting extension points.
We could start by first making everything in Route a RouteMixin, and then export Route as nothing more then a component that uses it. This would allow people to start adding their own custom behavior to their Route config.
The text was updated successfully, but these errors were encountered: