Created
December 16, 2014 23:48
-
-
Save ryanflorence/c1fe013af753456c1ca9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Authenticated = React.createClass({ | |
statics: { | |
willTransitionTo (transition) { | |
if (!authenticated()) { | |
transition.redirect('login'); | |
} | |
} | |
} | |
}); | |
var routes = ( | |
<Route handler={App}> | |
<Route handler={Authenticated}> | |
// put all authenticated routes here, since we don't require | |
// paths on routes, it won't mess with the url | |
</Route> | |
<Route handler={Public}> | |
// ... | |
</Route> | |
</Route> | |
); |
I assume you meant:
var Authenticated = React.createClass({
statics: {
willTransitionTo: function(transition) {
if (!authenticated()) {
transition.redirect('login');
}
}
}
});
In which case you get Uncaught Error: Invariant Violation: createClass(...): Class specification must implement a
rendermethod.
:(
Returning a RouteHandler will work.
render() {
return <RouteHandler />
}
In this case routes order make sense. Authenticated
handler will block Public
group when auth hasn't been done yet as it intercepts the routing flow.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍