Skip to content

Instantly share code, notes, and snippets.

@sebastialonso
Created December 4, 2016 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastialonso/6ce6993050f9d9f63fc04a8159f6be37 to your computer and use it in GitHub Desktop.
Save sebastialonso/6ce6993050f9d9f63fc04a8159f6be37 to your computer and use it in GitHub Desktop.
Router_middleware
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import thunk from 'redux-thunk';
import allReducers from './reducers/root_reducer';
let createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const RouterComponent = (props) => {
const routes = (
// blabla all routes
<Route path='/' component={BaseComponent}>
<IndexRedirect to="/data"/>
<Route path='data' component={DataComponents.index} onEnter={checkLogin}/>
</Route>
return (
<Provider store={createStoreWithMiddleware(allReducers)}>
<Router history={hashHistory} routes={routes} />
</Provider>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment