Skip to content

Instantly share code, notes, and snippets.

@mohandere
Last active February 19, 2018 10:07
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 mohandere/bb7a3f4efdf0de240954204dfa436183 to your computer and use it in GitHub Desktop.
Save mohandere/bb7a3f4efdf0de240954204dfa436183 to your computer and use it in GitHub Desktop.
react-router-redux integration example
// 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