Skip to content

Instantly share code, notes, and snippets.

@moog16
Created March 9, 2017 04:22
Show Gist options
  • Select an option

  • Save moog16/0d8eaf90de119f45968fbf76c15a3c8c to your computer and use it in GitHub Desktop.

Select an option

Save moog16/0d8eaf90de119f45968fbf76c15a3c8c to your computer and use it in GitHub Desktop.
RootContainer for new hot loader syntax
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