Created
March 9, 2017 04:22
-
-
Save moog16/0d8eaf90de119f45968fbf76c15a3c8c to your computer and use it in GitHub Desktop.
RootContainer for new hot loader syntax
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
| import React from 'react'; | |
| import { Router, Route, IndexRedirect, browserHistory } from 'react-router'; | |
| import { syncHistoryWithStore } from 'react-router-redux'; | |
| import { AppContainer } from './components/App'; | |
| import { RandomContainer } from './components/Random'; | |
| export default React.createClass({ | |
| history: null, | |
| _routes: null, | |
| componentWillMount() { | |
| const history = syncHistoryWithStore(browserHistory, this.props.store); | |
| this.history = history; | |
| this._routes = this.setupRoutes(); | |
| }, | |
| setupRoutes() { | |
| return ( | |
| <Route path="/" component={AppContainer}> | |
| <IndexRedirect to='random' /> | |
| <Route name='random' path='search' component={RandomContainer} /> | |
| </Route> | |
| ); | |
| }, | |
| render() { | |
| return ( | |
| <Router history={this.history}> | |
| {this._routes} | |
| </Router> | |
| ); | |
| } | |
| }) | |
| export { routeConfig }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment