0
所以,我檢查了終極版的代碼庫,終極版增強和applyMiddleware
要創建一個店,我們稱之爲由終極版曝光的createStore功能,
createStore(ourReducer,{}, applyMiddleware(someMiddleware));
export default function createStore(reducer, preloadedState, enhancer) {
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
enhancer = preloadedState
preloadedState = undefined
}
if (typeof enhancer !== 'undefined') {
if (typeof enhancer !== 'function') {
throw new Error('Expected the enhancer to be a function.')
}
return enhancer(createStore)(reducer, preloadedState)
} ...
在createStore以上功能,增強被稱爲在這一部分,這也是我在第一行通過applyMiddleware功能...
enhancer(createStore)(reducer, preloadedState)
但是,當我檢查了applyMiddleware功能,有3個參數 (減速機,preloadedState,增強劑)...
export default function applyMiddleware(...middlewares) {
return (createStore) => (reducer, preloadedState, enhancer) => {
...
它基本上總是不確定的吧?我只是好奇爲什麼它在那裏,或者我錯過了什麼。
enhancer(createStore)(reducer, preloadedState)