You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
618 B
32 lines
618 B
import React from 'react'; |
|
import Router, { RouteHandler } from 'react-router'; |
|
|
|
class App extends React.Component { |
|
constructor( props, context ) { |
|
super(); |
|
this.publishRouter( context.router ); |
|
} |
|
render() { |
|
return ( |
|
<RouteHandler /> |
|
); |
|
} |
|
publishRouter( router ){ |
|
var routes = {}; |
|
|
|
// Use route names as constants |
|
router.routes[0].childRoutes.forEach( function( r ){ |
|
routes[ r.name ] = r.path; |
|
}); |
|
|
|
// Render the router accessible without contexts |
|
Router.currentRouter = router; |
|
Router.routes = routes; |
|
} |
|
} |
|
|
|
App.contextTypes = { |
|
router: React.PropTypes.func |
|
}; |
|
|
|
export default App;
|
|
|