Skip to content

Commit

Permalink
feat(cli): redux 模板加入 redux-devtools 配置,close #1246
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Nov 26, 2018
1 parent 549045c commit 472ced8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/taro-cli/templates/redux/store/indexjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { createStore, applyMiddleware } from 'redux'
import { createStore, applyMiddleware, compose } from 'redux'
import thunkMiddleware from 'redux-thunk'
import rootReducer from '../reducers'

const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
}) : compose

const middlewares = [
thunkMiddleware
]
Expand All @@ -10,7 +17,12 @@ if (process.env.NODE_ENV === 'development') {
middlewares.push(require('redux-logger').createLogger())
}

const enhancer = composeEnhancers(
applyMiddleware(...middlewares),
// other store enhancers if any
)

export default function configStore () {
const store = createStore(rootReducer, applyMiddleware(...middlewares))
const store = createStore(rootReducer, enhancer)
return store
}

0 comments on commit 472ced8

Please sign in to comment.