将redux-batched-actions插入我现有的Redux存储中的正确方法是什么?我完全被Redux中间件API搞糊涂了。
目前我使用的是redux-thunk和redux-little-router。
下面是创建我的Redux存储的代码源代码:
import { createStore, applyMiddleware, compose, combineReducers } from 'redux'
import thunk from 'redux-thunk'
import { routerForBrowser } from 'redux-little-router'
import reducers from './store'
import routes from './routes'
const { reducer, middleware, enhancer } = routerForBrowser({ routes })
// Combine all reducers and instantiate the app-wide store instance
const allReducers = combineReducers({ ...reducers, router: reducer })
// Build middleware (if devTools is installed, connect to it)
const allEnhancers = (window.__REDUX_DEVTOOLS_EXTENSION__
? compose(
enhancer,
applyMiddleware(thunk, middleware),
window.__REDUX_DEVTOOLS_EXTENSION__())
: compose(
enhancer,
applyMiddleware(thunk, middleware)))
// Instantiate the app-wide store instance
const initialState = window.initialReduxState
const store = createStore(
allReducers,
initialState,
allEnhancers
)redux-batched-actions documentation公开了两种用法:enableBatching和batchDispatchMiddleware。在我的案例中,我应该使用哪一个?
https://stackoverflow.com/questions/51406632
复制相似问题