Last active
August 29, 2015 14:26
-
-
Save blittle/fef523bff4767f8b3ac9 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
import React from 'react'; | |
import './app.style.css!'; | |
class App extends React.Component { | |
static contextTypes = { | |
router: React.PropTypes.any | |
} | |
componentWillMount() { | |
if (this.props.location.pathname === '/') { | |
this.context.router.transitionTo(`/tabs/0/forms/dashboard`) | |
} | |
} | |
render() { | |
return ( | |
<div> | |
<div className=''> | |
{this.props.children} | |
</div> | |
</div> | |
) | |
} | |
} | |
export default App; |
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
import React from 'react'; | |
import { Router, Route } from 'react-router'; | |
import { createStore, combineReducers, applyMiddleware } from 'redux'; | |
import { Provider } from 'react-redux'; | |
import thunk from 'redux-thunk'; | |
import App from './app.component'; | |
import Tabs from './tabs/tabs.component'; | |
import Dashboard from 'src/dashboard/dashboard.component'; | |
import tabsReducer from 'src/tabs/tabs.reducer'; | |
const reducer = combineReducers({ | |
tabs: tabsReducer | |
}); | |
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore); | |
const store = createStoreWithMiddleware(reducer); | |
export default class Root extends React.Component { | |
render() { | |
const { history } = this.props; | |
return ( | |
<Provider store={store}> | |
{renderRoutes.bind(null, history)} | |
</Provider> | |
) | |
} | |
} | |
function renderRoutes(history) { | |
return ( | |
<Router history={history}> | |
<Route path="/" component={App}> | |
<Route path="/tabs/:tabId" component={Tabs}> | |
<Route path="/dashboard" component={Dashboard}/> | |
</Route> | |
</Route> | |
</Router> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment