Last active
August 29, 2015 14:10
-
-
Save insin/f8f04d46a82c2832a3e0 to your computer and use it in GitHub Desktop.
Getting the route <RouteHandler/> will render - API for this?
This file contains hidden or 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 {Route, RouteHandler} = ReactRouter | |
var App = React.createClass({ | |
contextTypes: { | |
getRouteAtDepth: React.PropTypes.func.isRequired, | |
routeHandlers: React.PropTypes.array.isRequired | |
}, | |
render() { | |
var route = this.context.getRouteAtDepth(this.context.routeHandlers.length - 1) | |
return <div className={route.handler.fluid ? 'container-fluid' : 'container'}> | |
<RouteHandler/> | |
</div> | |
} | |
}) | |
var RegularThing = React.createClass({ | |
render() { | |
// ... | |
} | |
}) | |
var HugeThing = React.createClass({ | |
statics: { | |
fluid: true | |
}, | |
render() { | |
// ... | |
} | |
}) | |
var routes = <Route handler={App} path="/"> | |
<Route name="regular" path="/regular" handler={RegularThing}/> | |
<Route name="huge" path="/huge" handler={HugeThing}/> | |
</Route> | |
ReactRouter.run(routes, function(Handler) { | |
React.render(<Handler/>, document.body) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment