Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 11, 2018. It is now read-only.

Commit0df2690

Browse files
author
David Zukowski
committed
upgrade(react-router-redux): ^3.0.0 -> ^4.0.0-beta
1 parent3b57c1c commit0df2690

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"better-npm-run":"0.0.5",
6161
"co-request":"^1.0.0",
6262
"debug":"^2.2.0",
63-
"history":"^2.0.0-rc2",
63+
"history":"^2.0.0",
6464
"iconv-lite":"^0.4.13",
6565
"koa":"^2.0.0-alpha.3",
6666
"koa-connect-history-api-fallback":"^0.3.0",
@@ -70,7 +70,7 @@
7070
"react-dom":"^0.14.0",
7171
"react-redux":"^4.0.0",
7272
"react-router":"^2.0.0",
73-
"react-router-redux":"^3.0.0",
73+
"react-router-redux":"^4.0.0-beta",
7474
"redux":"^3.0.0",
7575
"redux-thunk":"^1.0.0",
7676
"url":"^0.11.0",

‎src/main.js‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
importReactfrom'react'
22
importReactDOMfrom'react-dom'
33
import{browserHistory}from'react-router'
4+
import{syncHistoryWithStore}from'react-router-redux'
45
importmakeRoutesfrom'./routes'
56
importRootfrom'./containers/Root'
67
importconfigureStorefrom'./redux/configureStore'
78

9+
// Create redux store and sync with react-router-redux. We have installed the
10+
// react-router-redux reducer under the key "router" in src/routes/index.js,
11+
// so we need to provide a custom `selectLocationState` to inform
12+
// react-router-redux of its location.
813
constinitialState=window.__INITIAL_STATE__
9-
conststore=configureStore({ initialState, history})
14+
conststore=configureStore(initialState)
15+
consthistory=syncHistoryWithStore(browserHistory,store,{
16+
selectLocationState:(state)=>state.router
17+
})
1018

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

13-
// Render the React application to the DOM
24+
// Now that redux and react-router have been configured, we can render the
25+
// React application to the DOM!
1426
ReactDOM.render(
15-
<Roothistory={browserHistory}routes={routes}store={store}/>,
27+
<Roothistory={history}routes={routes}store={store}/>,
1628
document.getElementById('root')
1729
)

‎src/redux/configureStore.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import{applyMiddleware,compose,createStore}from'redux'
2-
import{syncHistory}from'react-router-redux'
32
importthunkfrom'redux-thunk'
43
importrootReducerfrom'./rootReducer'
54

6-
exportdefaultfunctionconfigureStore({ initialState={}, history}){
7-
// Sync with router via history instance (main.js)
8-
constrouterMiddleware=syncHistory(history)
9-
5+
exportdefaultfunctionconfigureStore(initialState={}){
106
// Compose final middleware and use devtools in debug environment
11-
letmiddleware=applyMiddleware(thunk,routerMiddleware)
7+
letmiddleware=applyMiddleware(thunk)
128
if(__DEBUG__){
139
constdevTools=window.devToolsExtension
1410
?window.devToolsExtension()
@@ -18,7 +14,6 @@ export default function configureStore ({ initialState = {}, history }) {
1814

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

2318
if(module.hot){
2419
module.hot.accept('./rootReducer',()=>{

‎src/redux/rootReducer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{combineReducers}from'redux'
2-
import{routeReducerasrouter}from'react-router-redux'
2+
import{routerReducerasrouter}from'react-router-redux'
33
importcounterfrom'./modules/counter'
44

55
exportdefaultcombineReducers({

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp