Last active
February 19, 2018 10:07
-
-
Save mohandere/bb7a3f4efdf0de240954204dfa436183 to your computer and use it in GitHub Desktop.
react-router-redux integration example
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
// src/index.js | |
import createHistory from 'history/createBrowserHistory' | |
import { ConnectedRouter, routerReducer } from 'react-router-redux' | |
import { Route } from 'react-router' | |
import { Provider } from 'react-redux' | |
// Other imports ... | |
// Add the reducer to your store on the `router` key | |
// Also apply our middleware for navigating | |
const store = createStore( | |
combineReducers({ | |
router: routerReducer | |
}) | |
) | |
ReactDOM.render( | |
<Provider store={store}> | |
{ /* ConnectedRouter will use the store from Provider automatically */ } | |
<ConnectedRouter history={history}> | |
<div> | |
<Route exact path="/" component={Home}/> | |
<Route path="/about" component={About}/> | |
<Route path="/topics" component={Topics}/> | |
</div> | |
</ConnectedRouter> | |
</Provider>, | |
document.getElementById('root') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment