Skip to content

Commit 69f7dbc

Browse files
author
lewis617
committed
chrome extend
1 parent e7d729b commit 69f7dbc

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

redux-examples/counter/store/configureStore.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { createStore, applyMiddleware } from 'redux'
1+
import { createStore, applyMiddleware,compose } from 'redux'
22
import thunk from 'redux-thunk'
33
import reducer from '../reducers'
44

55
//applyMiddleware来自redux可以包装 store 的 dispatch
66
//thunk作用是使被 dispatch 的 function 会接收 dispatch 作为参数,并且可以异步调用它
7-
const createStoreWithMiddleware = applyMiddleware(
8-
thunk
7+
const createStoreWithMiddleware = compose(
8+
applyMiddleware(
9+
thunk
10+
),
11+
window.devToolsExtension ? window.devToolsExtension() : f => f
912
)(createStore)
1013

1114
export default function configureStore(initialState) {

redux-examples/todomvc/store/configureStore.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { createStore } from 'redux'
1+
import { createStore ,compose} from 'redux'
22
import rootReducer from '../reducers'
33

4+
const finalCreateStore = compose(
5+
window.devToolsExtension ? window.devToolsExtension() : f => f
6+
)(createStore);
7+
48
export default function configureStore(initialState) {
5-
const store = createStore(rootReducer, initialState)
9+
const store = finalCreateStore(rootReducer, initialState);
610

711
if (module.hot) {
812
// Enable Webpack hot module replacement for reducers

0 commit comments

Comments
 (0)