Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
upgrade(react-router-redux): ^3.0.0 -> ^4.0.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
David Zukowski committed Feb 12, 2016
1 parent 3b57c1c commit 0df2690
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"better-npm-run": "0.0.5",
"co-request": "^1.0.0",
"debug": "^2.2.0",
"history": "^2.0.0-rc2",
"history": "^2.0.0",

This comment has been minimized.

Copy link
@bratva

bratva Jan 11, 2017

If i'm right, you don't use this module

"iconv-lite": "^0.4.13",
"koa": "^2.0.0-alpha.3",
"koa-connect-history-api-fallback": "^0.3.0",
Expand All @@ -70,7 +70,7 @@
"react-dom": "^0.14.0",
"react-redux": "^4.0.0",
"react-router": "^2.0.0",
"react-router-redux": "^3.0.0",
"react-router-redux": "^4.0.0-beta",
"redux": "^3.0.0",
"redux-thunk": "^1.0.0",
"url": "^0.11.0",
Expand Down
18 changes: 15 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import makeRoutes from './routes'
import Root from './containers/Root'
import configureStore from './redux/configureStore'

// Create redux store and sync with react-router-redux. We have installed the
// react-router-redux reducer under the key "router" in src/routes/index.js,
// so we need to provide a custom `selectLocationState` to inform
// react-router-redux of its location.
const initialState = window.__INITIAL_STATE__
const store = configureStore({ initialState, history })
const store = configureStore(initialState)
const history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: (state) => state.router
})

// Now that we have the Redux store, we can create our routes. We provide
// the store to the route definitions so that routes have access to it for
// hooks such as `onEnter`.
const routes = makeRoutes(store)

// Render the React application to the DOM
// Now that redux and react-router have been configured, we can render the
// React application to the DOM!
ReactDOM.render(
<Root history={browserHistory} routes={routes} store={store} />,
<Root history={history} routes={routes} store={store} />,
document.getElementById('root')
)
9 changes: 2 additions & 7 deletions src/redux/configureStore.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { applyMiddleware, compose, createStore } from 'redux'
import { syncHistory } from 'react-router-redux'
import thunk from 'redux-thunk'
import rootReducer from './rootReducer'

export default function configureStore ({ initialState = {}, history }) {
// Sync with router via history instance (main.js)
const routerMiddleware = syncHistory(history)

export default function configureStore (initialState = {}) {
// Compose final middleware and use devtools in debug environment
let middleware = applyMiddleware(thunk, routerMiddleware)
let middleware = applyMiddleware(thunk)
if (__DEBUG__) {
const devTools = window.devToolsExtension
? window.devToolsExtension()
Expand All @@ -18,7 +14,6 @@ export default function configureStore ({ initialState = {}, history }) {

// Create final store and subscribe router in debug env ie. for devtools
const store = middleware(createStore)(rootReducer, initialState)
if (__DEBUG__) routerMiddleware.listenForReplays(store, ({ router }) => router.location)

if (module.hot) {
module.hot.accept('./rootReducer', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/redux/rootReducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { combineReducers } from 'redux'
import { routeReducer as router } from 'react-router-redux'
import { routerReducer as router } from 'react-router-redux'
import counter from './modules/counter'

export default combineReducers({
Expand Down

0 comments on commit 0df2690

Please sign in to comment.